-
Notifications
You must be signed in to change notification settings - Fork 0
feat(browser): fail closed on oversized Agent Task observation #128
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
Draft
seonghobae
wants to merge
6
commits into
test/agent-task-structured-value-evidence
Choose a base branch
from
test/agent-task-observation-bound
base: test/agent-task-structured-value-evidence
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.
+87
−12
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
71e7878
test(browser): require bounded semantic observation evidence
seonghobae a18730b
fix(browser): bound Agent Task semantic observation evidence
seonghobae 58917b0
test(browser): bound semantic locator text
seonghobae 24446c9
test(browser): restore bounded observation contract
seonghobae 2d79ef2
Merge current structured evidence into observation bound
seonghobae f60771f
docs: record bounded Agent Task observation evidence
seonghobae 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| """Contract for bounded semantic-observation evidence in the controlled Agent Task.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pathlib | ||
| import runpy | ||
| import unittest | ||
|
|
||
| ROOT = pathlib.Path(__file__).resolve().parents[1] | ||
| RUNNER = ROOT / "scripts" / "ci" / "run_mv3_compatibility.py" | ||
|
|
||
|
|
||
| class AgentTaskObservationBoundContractTests(unittest.TestCase): | ||
| """Require the pinned-browser Agent Task to fail closed on oversized observations.""" | ||
|
|
||
| @classmethod | ||
| def setUpClass(cls) -> None: | ||
| cls.namespace = runpy.run_path( | ||
| str(RUNNER), run_name="agent_task_observation_bound_contract" | ||
| ) | ||
|
|
||
| def test_semantic_observation_has_an_explicit_byte_limit(self) -> None: | ||
| """The runner must expose one finite semantic-observation byte ceiling.""" | ||
|
|
||
| self.assertIn("MAX_AGENT_TASK_SEMANTIC_OBSERVATION_BYTES", self.namespace) | ||
| maximum = self.namespace["MAX_AGENT_TASK_SEMANTIC_OBSERVATION_BYTES"] | ||
| self.assertIsInstance(maximum, int) | ||
| self.assertGreater(maximum, 0) | ||
| self.assertLessEqual(maximum, 64 * 1024) | ||
|
|
||
| def test_observation_measurement_accepts_exact_limit_and_rejects_overflow(self) -> None: | ||
| """Canonical UTF-8 evidence at the ceiling is valid; one byte over fails closed.""" | ||
|
|
||
| self.assertIn("_measure_agent_task_semantic_observation_bytes", self.namespace) | ||
| helper = self.namespace["_measure_agent_task_semantic_observation_bytes"] | ||
| maximum = self.namespace["MAX_AGENT_TASK_SEMANTIC_OBSERVATION_BYTES"] | ||
|
|
||
| # Canonical compact JSON for {"x":"..."} uses exactly eight structural bytes. | ||
| exact = {"x": "a" * (maximum - 8)} | ||
| oversized = {"x": "a" * (maximum - 7)} | ||
| self.assertEqual(helper(exact), maximum) | ||
| with self.assertRaises(ValueError): | ||
| helper(oversized) | ||
| with self.assertRaises(ValueError): | ||
| helper({}) | ||
| with self.assertRaises(TypeError): | ||
| helper("not-an-observation") | ||
|
|
||
| def test_real_agent_task_path_uses_the_bounded_measurement_helper(self) -> None: | ||
| """The real controlled browser pass must not bypass the bounded helper.""" | ||
|
|
||
| runner = RUNNER.read_text(encoding="utf-8") | ||
| self.assertIn( | ||
| "semantic_observation_bytes = _measure_agent_task_semantic_observation_bytes(", | ||
| runner, | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
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.
📝 Info: Oversized observation fails closed via trial exception path
_measure_agent_task_semantic_observation_bytesraisesValueErroron oversized or empty input; this propagates to the trial loop inmain, which catches it and records a failed trial. The observation is built only from fixed short role/name strings, so the 4096-byte cap is defensive and cannot trigger with the controlled fixture.Was this helpful? React with 👍 or 👎 to provide feedback.