-
Notifications
You must be signed in to change notification settings - Fork 806
Update contact multiple surfaces sample #569
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
base: main
Are you sure you want to change the base?
Update contact multiple surfaces sample #569
Conversation
- Add a base InferenceStrategy class - Add PackSpecsBuildHook to copy JSON schemas into the package during build time. - Update pyproject.toml to include assets and configure the build hook. - Implement A2uiSchemaManager for robust schema loading, pruning, and prompt generation.
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.
Code Review
This pull request introduces a new a2ui-agent Python package with a centralized A2uiSchemaManager for handling A2UI schemas. This is a great architectural improvement, moving away from hardcoded schemas in the sample agents. The manager provides robust, multi-layered logic for loading schemas from package resources or the source repository, and includes functionality for bundling, pruning, and validating schemas. The sample agents (contact_lookup and contact_multiple_surfaces) are refactored to use this new manager, simplifying their code and making them more maintainable. The changes also include a Hatch build hook to package the schema files correctly and new tests for the added functionality.
I've found a couple of issues: one in a __main__ block in contact_lookup/prompt_builder.py that would cause a TypeError if run directly, and a logic error in contact_multiple_surfaces/agent.py where a check for a loaded schema was referencing a method instead of a property. I've provided suggestions to fix both. Overall, this is a well-executed and beneficial refactoring.
|
|
||
| # Ensure schema was loaded | ||
| if self.use_ui and self.a2ui_schema_object is None: | ||
| if self.use_ui and self._schema_manager.bundle_schemas is None: |
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 check for a loaded schema is incorrect. self._schema_manager.bundle_schemas refers to the method itself, which will never be None. You should check the bundled_schema property instead, which holds the result of the schema bundling. This will ensure the error handling for a missing schema triggers correctly.
| if self.use_ui and self._schema_manager.bundle_schemas is None: | |
| if self.use_ui and self._schema_manager.bundled_schema is None: |
| contact_prompt = A2uiSchemaManager("0.8", examples=CONTACT_UI_EXAMPLES).generate_system_prompt( | ||
| role_description=ROLE_DESCRIPTION, | ||
| workflow_description=WORKFLOW_DESCRIPTION, | ||
| ui_description=UI_DESCRIPTION, | ||
| include_examples=True, | ||
| ) |
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.
The arguments in this block are incorrect and will cause a TypeError when running the script directly.
- The
A2uiSchemaManagerconstructor does not accept anexamplesargument. The examples should be passed to thegenerate_system_promptmethod instead. - The
generate_system_promptmethod does not have aninclude_examplesparameter; you should use theexamplesparameter.
| contact_prompt = A2uiSchemaManager("0.8", examples=CONTACT_UI_EXAMPLES).generate_system_prompt( | |
| role_description=ROLE_DESCRIPTION, | |
| workflow_description=WORKFLOW_DESCRIPTION, | |
| ui_description=UI_DESCRIPTION, | |
| include_examples=True, | |
| ) | |
| schema_manager = A2uiSchemaManager("0.8") | |
| contact_prompt = schema_manager.generate_system_prompt( | |
| role_description=ROLE_DESCRIPTION, | |
| workflow_description=WORKFLOW_DESCRIPTION, | |
| ui_description=UI_DESCRIPTION, | |
| examples=CONTACT_UI_EXAMPLES, | |
| ) |
aa19535 to
a2cc041
Compare
Tested: - [x] The contact_lookup client successfully connected to the contact_lookup agent and rendered the response correctly.
Introduces a `schema_modifiers` parameter to A2uiSchemaManager, allowing custom callable hooks to transform schemas after loading. This enables flexible schema customization, such as relaxing strict validation constraints during testing.
It updates the sample to use the A2uiSchemaManager from the a2ui-agent python SDK. Tested: - [x] The `contact` angular client successfully connected to the `contact_multiple_surfaces` agent and rendered the response correctly.
a2cc041 to
3eb5cf5
Compare
Description
It updates the sample to use the A2uiSchemaManager from the a2ui-agent python SDK.
Tested:
contactangular client successfully connected to thecontact_multiple_surfacesagent and rendered the response correctly.Pre-launch Checklist
If you need help, consider asking for advice on the discussion board.