generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 605
fix: include both text and structured_output in AgentResult.__str__ #1472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
strands-agent
wants to merge
7
commits into
strands-agents:main
Choose a base branch
from
strands-agent:fix/agent-result-str-structured-output
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+245
−61
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d6b371a
fix: include both text and structured_output in AgentResult.__str__ (…
strands-agent 09ed648
fix: output structured output in JSON format for parseability
047eab1
chore: remove Option 1 references from comments
strands-agent aab265b
refactor(tests): consolidate __str__ tests into test_agent_result.py
42daada
fix: preserve text content without modification
strands-agent 8e82e27
chore: apply hatch formatter and linter fixes
strands-agent 85ace40
lint
afarntrog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems odd to me; we're using a
strrepresentation to include JSON; I think ofstras human readable and this seems to go the opposite direction.If anything, I would expect the JSON to be appended to the text at the end, not JSON-stringified. If we wanted both the JSON and the string text, why not use the AgentResult directly to get those items?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or a better question:
Why is:
A goal of
__str__?If, we're attempting to fix:
I don't think JSON in str is the right answer - though perhaps I'm the minority in that opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ultimately stringified json though. The benefit I see of using json in the string is that gives users the flexibility of parsing the str if they want. I don't think it'll degrade the str output. It'll provide more flexibility
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going from:
to:
Still doesn't make sense to me. Why are we special casing that when you have structured_output,
__str__is JSON-fying the entire thing?If you want it strongly typed/structured use AgentResult, if you want it as a string, call
__str__but I think conflating the two is odd.Whereas this makes more sense:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering what’s stopping us from appending
structured_outputright after line 1004 (though we should skip adding duplicate JSON strings when there’s no text present)?sdk-python/src/strands/multiagent/graph.py
Lines 1002 to 1005 in 318573d