Repository navigation
[FD-3805] feat(prompt_agent): grade on max-steps terminal instead of retrying #138
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
williamloo-scale
wants to merge
2
commits into
main
Choose a base branch
from
wloo/prompt-agent-max-steps-grade-no-retry
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.
Open
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| """A max-turns budget exhaustion records an ``error_type``, but its partial work is | ||
| still gradable. Verifiers skip responses with an ``error_type`` *unless* the error is | ||
| a ``MAX_TURNS_ERROR_CODE`` budget outcome — these tests pin that carve-out so a | ||
| budget-exhausted run reaches grading instead of being silently skipped.""" | ||
|
|
||
| import pytest | ||
|
|
||
| from agent_env.a2a_agent.protocol import MAX_TURNS_ERROR_CODE | ||
| from agent_env.task_step.context import PromptResponse, TaskStepContext | ||
| from agent_env.task_step.task_steps.verifiers.agent_prompt_response_verifier import ( | ||
| AgentPromptResponseVerifierTaskStep, | ||
| ) | ||
|
|
||
|
|
||
| def test_is_gradable_despite_error_only_for_max_turns(): | ||
| assert PromptResponse( | ||
| prompt_id="p1", response="x", error_type="agent_error", error_code=MAX_TURNS_ERROR_CODE, | ||
| ).is_gradable_despite_error | ||
| assert not PromptResponse( | ||
| prompt_id="p1", response="x", error_type="agent_error", error_code="some_crash", | ||
| ).is_gradable_despite_error | ||
| assert not PromptResponse(prompt_id="p1", response="x").is_gradable_despite_error | ||
|
|
||
|
|
||
| def _context_with_response(**kw) -> TaskStepContext: | ||
| ctx = TaskStepContext(instance_id="ti-1") | ||
| ctx.prompt_responses.append(PromptResponse(prompt_id="p1", response="the answer is 42", **kw)) | ||
| return ctx | ||
|
|
||
|
|
||
| def _verifier() -> AgentPromptResponseVerifierTaskStep: | ||
| return AgentPromptResponseVerifierTaskStep( | ||
| id="v", version=None, prompt_id="p1", verifier_id="vid", | ||
| criteria=[{"type": "response_contains", "needles": ["42"]}], | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_max_turns_error_reaches_grading(): | ||
| # A budget-exhausted response carries error_type but is gradable: the verifier | ||
| # must evaluate its criteria against the partial response, not skip it. | ||
| ctx = _context_with_response(error_type="agent_error", error_code=MAX_TURNS_ERROR_CODE) | ||
|
|
||
| result = await _verifier().execute(ctx) | ||
|
|
||
| entry = result.metadata["verifications"]["vid"] | ||
| assert entry["results"][0].get("id") != "prompt_error" # not the skipped sentinel | ||
| assert entry["results"][0]["result"] is True | ||
| assert entry["score"] == 1.0 | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_other_error_type_still_skips_grading(): | ||
| # A real crash (any other error_code) must still short-circuit to a skip. | ||
| ctx = _context_with_response(error_type="agent_error", error_code="some_crash") | ||
|
|
||
| result = await _verifier().execute(ctx) | ||
|
|
||
| entry = result.metadata["verifications"]["vid"] | ||
| assert entry["results"][0]["id"] == "prompt_error" | ||
| assert entry["score"] == 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.