Repository navigation
feat(harness): record why a rebuild drops a scenario for a removed capability and restore it under its key when the capability returns (TH-8754) - #325
Draft
KarthikAvinashFI wants to merge 7 commits into
Conversation
…pability, and restore it under its key once the capability returns
…ore-dropped-scenarios
…nario digest never reads it
…ore-dropped-scenarios
…ore-dropped-scenarios
…ore-dropped-scenarios
… declare_tool; fix_tool and adopt_tool say so instead of claiming the agent lacks it
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
TH-8754: when an agent version loses a tool, the scenario rebuild drops the cases that need it, and until now nothing remembered why. When the tool came back, the cases were gone for good: a rebuild wrote new ones under new keys, so their run history no longer lined up.
Now a rebuild records each case it drops for a removed capability (which tools and sub-goals it needed, which were missing, the agent version, a readable reason and the case's last content). When a later rebuild has every capability back, the case comes back under its own key from its last content, is proved like any other case, and is listed as restored.
What changed
src/fi/alk/harness/dropped.py(new)dropped.jsonbeside the scenarios:record_drops(from the turn-start snapshot, only drops whose needed tools or sub-goals are missing),restore(every record whose capabilities are all back goes into the kept list under its key),finish_restore(a restored case that fails its proof or is dropped again stays recorded withrestore_failedand the why),submit_refusal(a rebuild may bring a dropped key back only by restore),restore_note.save({})removes the file.src/fi/alk/harness/nudge.pyreport_update, restores at the start of the turn, and reportsrestoredandrestore_failed.src/fi/alk/harness/hosted_chat_entrypoint.pysrc/fi/alk/harness/skills/builder/topics/agent-update.mddeclare_tool.src/fi/alk/harness/amend.pyfix_toolandadopt_toolon a tool the contract lacks said "is not a tool this agent has"; they now say it is not in the contract and point atdeclare_tool. Found live: the builder took the old message at its word and never added the tool back, so nothing could be restored.Behavior callouts
HARNESS_VERSIONING_NUDGES_ENABLEDon. Production values do not set it today, so this feature does nothing in production until that flag is on.Tests
tests/harness/test_dropped_scenarios.py, 13 tests: a v5 drop records capabilities, agent and reason; an ordinary drop is not recorded; no restore while the capability is still missing; restore under the same keys and last content when it returns; restored cases are proved; restore only once every capability is back; a repeatedreport_updatekeeps the restore listed; the message names the restored cases and a changed argument; a restore that cannot be proved stays dropped with why; a restored case dropped again is a failed restore; a rebuild cannot write a new case under a dropped key; editing a restored case is allowed; with no drops leftdropped.jsonis removed and the scenario digest never reads it (so the platform hashes such a suite exactly as before).Also
tests/test_harness.py::test_fixing_a_tool_the_contract_lacks_points_at_declare_tool.Run on this branch (the targeted harness modules, one process): 2654 pass; three failures, the same on
dev(0203bdf5). Mutations: keeping an emptydropped.jsonfails the last test; the old refusal text fails thedeclare_tooltest.Break-it attempts (throwaway tests), all hold: a corrupt
dropped.jsonreads as no drops and restores nothing; a record whose content no longer reads as a scenario is refused with why while the others restore; a restore whose name a kept case now holds is refused; restoring twice restores nothing the second time;submit_refusalwith empty, null or padded keys.Live proof
See future-agi
feat/TH-8754-restore-dropped-scenariosfor the screenshots; the run is summarised here.Local stack with production sandbox specs, a chat demo environment (deals desk) on its environment v12, the last version before tools were added through chat. Rebuild nudges turned on locally (see the callout). Agent v3 is v1's source with the
apply_discounttool removed.apply_discountleaves the contract; the suite rebuild dropslive-manager-discount-negotiationandmanager-initiated-post-discussion-workflow; suite v10 keeps each drop with "agent v3 no longer hasapply_discount; the environment retiredapplied_discount_to_deal", the missing tools and sub-goals, and the agent version; the version diff carries the same reason422 scenario_key_retired: "live-manager-discount-negotiation was removed earlier and can't be reused; give the scenario a new name"apply_discountback withdeclare_tool(environment v18); the suite rebuild restores both cases under the same keys from their last content, proved by the gates; the card reads "2 scenarios restored" and lists them under RestoredSuite v10's diff (
GET versions/suite/{id}/diff/), removed entries:{"key": "live-manager-discount-negotiation", "reason": "agent v3 no longer has `apply_discount`; the environment retired `applied_discount_to_deal`", "capabilities": {"tools": ["apply_discount"], "sub_goals": ["applied_discount_to_deal"]}, "agent_version": "v3"}Found while running it, fixed here and in the harness PR: the rebuild card's change list showed the generic "removed when the environment was updated" instead of the stored reason (
ad6acfdcf); and on the first attempt the environment rebuild did not putapply_discountback (the harness told the builder it was "not a tool this agent has" when it was only missing from the contract), so nothing was restored. With the harness fix the second attempt restored both cases.The restored cases read Draft "No negative control" on the Scenarios tab: they were written before negative controls existed, which the lifecycle reports for any such case.
Stacked on / merge order
feat/TH-8918-scenario-lifecycle(feat(harness): negative controls, leaked-answer check, grounding and suite proving (TH-8918) #321), this PR's basefeat/TH-8754-restore-dropped-scenariosLinear: TH-8754