feat(agents): add step-level type discriminator (GAP-003)#2275
feat(agents): add step-level type discriminator (GAP-003)#2275kevinmessiaen merged 5 commits intomainfrom
Conversation
Adds StepType enum (TOOL_RESULT, COMPLETION) and step_type field to WorkflowStep, set automatically in _StepRunner.execute(). Made-with: Cursor
Summary of ChangesHello @Hartorn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the agent workflow by introducing a type discriminator for individual steps. This change allows for clearer identification of whether a step involved a tool execution or a direct completion, providing better visibility and potential for more granular analysis or control over the agent's execution path. The new Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a step_type discriminator to WorkflowStep, allowing to distinguish between TOOL_RESULT and COMPLETION steps. The implementation is clean and the new field is correctly populated within the _StepRunner. The addition of tests for this new feature is great, ensuring the logic is correct. I've found a minor issue in one of the new tests, where it doesn't seem to be verifying what its name and docstring suggest. My feedback includes a suggestion to address this.
| async def test_step_type_available_via_run(): | ||
| """step_type is set on the last step accessible through chat.""" | ||
| gen = MagicMock(spec=BaseGenerator) | ||
| gen.complete = AsyncMock( | ||
| return_value=Response( | ||
| message=Message(role="assistant", content="World!"), | ||
| finish_reason="stop", | ||
| ) | ||
| ) | ||
|
|
||
| chat = await ChatWorkflow(generator=gen).chat("Hello").run() | ||
|
|
||
| assert not chat.failed | ||
| assert chat.last.content == "World!" |
There was a problem hiding this comment.
This test is named test_step_type_available_via_run and its docstring says it tests that step_type is set on the last step. However, the test implementation doesn't assert anything about step_type. The run() method returns a Chat object, which doesn't expose the underlying WorkflowStep where step_type is defined. As it is, this test is a basic smoke test for the run() method and doesn't verify the step_type logic.
Consider one of the following options:
- Remove this test. The other tests in this file already provide good coverage for the
step_typefunctionality using thesteps()interface. - Modify the test to use
steps()to inspect the final step's type, similar to the other tests in this file. - Rename the test and update its docstring to reflect that it's a smoke test for
run(), although it might be better placed in a different test file.
Adds StepType enum (TOOL_RESULT, COMPLETION) and step_type field to WorkflowStep, set automatically in _StepRunner.execute().
Made-with: Cursor
Description
Related Issue
Type of Change
Checklist
CODE_OF_CONDUCT.mddocument.CONTRIBUTING.mdguide.pdm.lockrunningpdm update-lock(only applicable whenpyproject.tomlhas beenmodified)