Skip to content

Conversation

@whoisarpit
Copy link
Contributor

@whoisarpit whoisarpit commented May 6, 2025

Fixes #575

Summary

Adds support for nested dot-separated references in instruction templates. Users can now access deeply nested values in the state object using a simple dot notation, with optional markers at any level of the path.

This is useful when templating structured data from a previous LlmAgent using output_schema.

Changes

  • Enhanced _populate_values function to handle nested dot-separated references
  • Supports optional markers at any level with ? suffix (e.g., {user?.profile?.name?})
  • Updated existing tests and added new test cases for the nested templating functionality

Examples

Before:

# Only simple values were supported
"{customerId}" -> "1234567890"
"{user:profile}" -> "basic"
"{user.profile.name}" -> "{user.profile.name}"

After:

# Now supports nested references
"{user.profile.name}" -> "John Doe"
"{user.settings.theme}" -> "dark"

# Optional markers at any level
"{user?.profile?.email}" -> "[email protected]"
"{user?.preferences?.theme?}" -> "" (empty if path doesn't exist)

# Invalid paths without optional markers will not be templated instead of throwing an error to avoid breaking changes
"{user.invalid.path}" -> "{user.invalid.path}"

Use Cases

  • Accessing complex nested objects in state
  • Optional references that gracefully handle missing values
  • Better organization of state data with hierarchical structures

This feature enables more flexible template interpolation, allowing for cleaner, more organized state structures while maintaining backward compatibility with the existing flat state model.

@whoisarpit whoisarpit force-pushed the feat/nested_populate branch from eb3b49c to 012ef17 Compare May 6, 2025 06:43
@whoisarpit whoisarpit force-pushed the feat/nested_populate branch from 012ef17 to cd10aa0 Compare May 7, 2025 02:19
@whoisarpit whoisarpit changed the title Feature: Allow for nested templating in instructions Feature: Allow for templating of nested objects in instructions May 7, 2025
@hangfei hangfei requested a review from Jacksunwei May 30, 2025 19:22
@hangfei
Copy link
Collaborator

hangfei commented May 30, 2025

@Jacksunwei PTAL.

@surajksharma07 surajksharma07 self-assigned this Oct 3, 2025
@surajksharma07
Copy link
Collaborator

Hi @whoisarpit and thanks to everyone who participated in this thread.

We're currently doing some housekeeping on our pull request queue. Given the rapid pace of development and the number of updates since this was last active, there's a good chance this pull request needs to be caught up to the latest version. To help us keep our backlog focused on current pull requests, we are closing this as stale.

If you're still interested in contributing to this change, could you please update to the very latest version of the library and create a new pull request? Our team will be glad to help with the refreshed PRs and answer any questions!

Thanks for your contribution and understanding!”

@boyangsvl
Copy link
Collaborator

This is a good feature to have. @ryanaiagent could you help to review?

@boyangsvl boyangsvl reopened this Oct 29, 2025
@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Oct 29, 2025
@adk-bot
Copy link
Collaborator

adk-bot commented Oct 29, 2025

Response from ADK Triaging Agent

Hello @whoisarpit, thank you for your contribution! This is a great feature.

For future PRs, please remember to include a testing plan section in the description. This helps reviewers understand how you've tested the changes and speeds up the review process.

Thanks again!

@ryanaiagent
Copy link
Collaborator

Hi @whoisarpit, This PR has merge conflicts that require changes from your end. Could you please rebase your branch with the latest main branch to address these? Once this is complete, please let us know so we can proceed with the review.

@hangfei
Copy link
Collaborator

hangfei commented Nov 18, 2025

Closing due to inactivity. Please raise a new PR after you fix the conflicts.

@hangfei hangfei closed this Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support templating of nested values in instruction template

6 participants