-
Notifications
You must be signed in to change notification settings - Fork 46
feat: derive corrective turns from session judge #401
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
Merged
Merged
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion
2
reflexio/server/prompt/prompt_bank/agent_success_evaluation/v1.0.0.prompt.md
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
89 changes: 89 additions & 0 deletions
89
reflexio/server/prompt/prompt_bank/agent_success_evaluation/v1.1.0.prompt.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| --- | ||
| active: true | ||
| description: "Evaluates session success, escalation, and corrective user turns" | ||
| changelog: "v1.1.0: adds a required count of corrective user turns, distinguishes revisions from new intents, and keeps correction count independent from final task success." | ||
| variables: | ||
| - agent_context_prompt | ||
| - success_definition_prompt | ||
| - tool_can_use | ||
| - metadata_definition_prompt | ||
| - interactions | ||
| --- | ||
|
|
||
| [Instruction] | ||
| Given the interactions above, evaluate if the agent has successfully completed the user's primary requested task by the end of the session, based on the success definition below. | ||
| The agent may make mistakes or take wrong actions during the session. The user may provide corrections or ask the agent to try differently. These mid-session errors do NOT constitute failure — focus on the final outcome. As long as the user's primary task is completed successfully by the end of the session, set is_success to True. | ||
|
|
||
| Step 1: Identify the user's primary task from the interactions. Then determine if the agent has fulfilled this task by the end of the session based on the success definition. If so, set is_success to True. Otherwise set is_success to False and continue to the next step. | ||
|
|
||
| Step 2: If the agent did not complete the primary task by the end of the session, determine the failure type and failure reason. | ||
| There are four types of failures: | ||
| - 'missing_tool': Agent does not have the right tool or action that it can take to get sufficient information to answer the user's request. | ||
| - 'wrong_tool': Tools or actions are available, but the agent did not use the right tool or perform the right action. | ||
| - 'insufficient_info_from_tool': Agent performed the right action and tool use, but the tool or action did not provide enough or correct information to answer successfully. | ||
| - 'wrong_answer': Agent had enough information but still did not answer successfully. | ||
|
|
||
| Step 3: Determine if the user was escalated (handed off to a human agent or another agent). Set is_escalated to True if so, False otherwise. Escalation typically means the agent could not resolve the issue itself. Escalated sessions are likely unsuccessful, but unsuccessful sessions are not necessarily escalated. | ||
|
|
||
| Step 4: Count corrective user turns across the entire session. | ||
|
|
||
| A user turn is corrective only when ALL of these are true: | ||
| 1. It refers to an earlier agent response or action. | ||
| 2. It indicates explicitly or by strong implication that the earlier response or action was incorrect, incomplete, insufficient, or misaligned. | ||
| 3. It steers the agent toward revising that earlier response or action, such as by supplying corrected information, identifying missing content, changing a constraint, rejecting an approach, requesting a redo, or specifying how the response should change. | ||
|
|
||
| Count each qualifying user turn once, even if it corrects multiple issues. Count separate later corrective turns separately, including repeated corrections of the same issue. A correction may refer to an agent turn earlier than the immediately preceding turn. | ||
|
|
||
| Do NOT count: | ||
| - the user's initial request; | ||
| - a genuinely different question or a request for a separate new deliverable, even when it concerns the same general topic; | ||
| - an ordinary follow-up question that seeks additional information without indicating the earlier response should change; | ||
| - an answer to a clarification question asked by the agent; | ||
| - a confirmation, acknowledgment, approval, or request to continue; | ||
| - information supplied before the agent made the relevant mistake; | ||
| - an agent self-correction that was not prompted by a corrective user turn. | ||
|
|
||
| To distinguish a corrective turn from a new intent, ask whether the user is evaluating, modifying, rejecting, completing, or replacing an earlier agent response. Topic continuity alone is not evidence of a correction. If the new intent can be fulfilled without revising the earlier response, do not count it. | ||
|
|
||
| Set number_of_correction_per_session to the resulting non-negative integer. This count is independent of is_success: a session may contain corrective turns and still be successful if the primary task is completed by the end. | ||
|
|
||
| [Context] | ||
| {agent_context_prompt} | ||
|
|
||
| [Success definition] | ||
| {success_definition_prompt} | ||
|
|
||
| [Interactions] | ||
| User and agent interactions: | ||
| {interactions} | ||
|
|
||
| [Tools] | ||
| {tool_can_use} | ||
|
|
||
| [Metadata Definition] | ||
| {metadata_definition_prompt} | ||
|
|
||
| [Output] | ||
| Generate the output in valid JSON format using the following schema. | ||
|
|
||
| # success case example | ||
| ```json | ||
| {{ | ||
| "is_success": true, | ||
| "is_escalated": false, | ||
| "number_of_correction_per_session": 2 | ||
| }} | ||
| ``` | ||
|
|
||
| # failure case example | ||
| `failure_type` must be one of `missing_tool`, `wrong_tool`, `insufficient_info_from_tool`, or `wrong_answer`; this example uses `missing_tool`. | ||
|
|
||
| ```json | ||
| {{ | ||
| "is_success": false, | ||
| "failure_type": "missing_tool", | ||
| "failure_reason": "explain the reason for failure and what the agent needs to do differently", | ||
| "is_escalated": true, | ||
| "number_of_correction_per_session": 1 | ||
| }} | ||
| ``` | ||
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
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
3 changes: 2 additions & 1 deletion
3
...ce/TestMockResponseSnapshots.test_recorded_fixture_content[agent_success_evaluation].json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| { | ||
| "is_escalated": false, | ||
| "is_success": true | ||
| "is_success": true, | ||
| "number_of_correction_per_session": 0 | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.