Repository navigation
feat(agent): task ledger and ask-the-user over MCP - #1332
Merged
Merged
Conversation
Agents that use OpenAdapt over MCP can open a job and keep its state on the server: the user's rules (locked when the job opens), items with a status set only from OpenAdapt's own run and guarded-save results, evidence labelled trusted or untrusted, and yes-or-no questions for a person. - Eight tools: open_job, get_job, add_items, record_evidence, ask_user, get_answer, change_constraint, close_job. - run_workflow for a job item is refused when it breaks a typed rule, while a question about the item waits, or while the item needs a person. - Only a person changes a locked rule. - Questions are item-approval requests under <runs>/task-ledger, so they show on the paired phone and in Desktop's Run it; the console shows the question text. An answer must come from a person on a person's route. - A run that stops before saving, or a save that can't be confirmed, asks a person by itself, so a stop in a job reaches someone. - On by default when runs or guarded saves are; serve --no-ledger turns it off. Measured with a scripted agent on a 30-item synthetic MockMed worklist (python -m openadapt_flow.agent.ledger_demo, no model calls): rule breaks 12 -> 0, guesses 2 -> 0, unverified reported as done 2 -> 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # CAPABILITIES.md
# Conflicts: # CAPABILITIES.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
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.
What this does
Agents that use OpenAdapt over MCP can open a job and keep its state on the server instead of rebuilding it from their own history. OSWorld 2.0 (arXiv:2606.29537) found that on long workflows agents lose track of constraints, miss information that arrives mid-task, guess instead of asking, and skip verification. This PR addresses each of those.
open_job,get_job,add_items,record_evidence,ask_user,get_answer,change_constraint,close_job.run_workflowinput (equals,one_of,not_one_of). The server refuses a run for the job that breaks one ("Nothing ran."). Only a person changes a rule after that.run_workflow,get_run, and the guarded-save tools. No tool lets the agent set a status. A verified item never goes back.useris trusted;appanddocumentare never trusted, and evidence can't change a rule or a status.<runs>/task-ledger/, so it shows on the paired phone and in Desktop's Run it. Only an answer from a person on a person's route counts; the ledger checks it with Flow's ownanswer_refusal. Waits are bounded (0 to 600 s).serve --no-ledgerturns it off.Measurement (synthetic, no model calls)
python -m openadapt_flow.agent.ledger_demo: a scripted agent works a 30-item synthetic MockMed worklist through the real MCP server. The scenario has a rule change at item 13, a referral that tells the reader to mark everything urgent, two patients who share a name, and two unconfirmed saves. A simulated person answers through the console's own waiting list. The agent has the same fixed flaws in every arm.Enforcement alone stops every rule break. It can't stop an agent from guessing a value or misreporting its own tally, but
close_joblists what was verified, so a caller can check. The scripted agent stands for a policy, not a model, so these numbers test the mechanism. They aren't a model benchmark. Results:packages/agent/docs/task-ledger-measurement.json. No paid run: the machine's 1-minute load was far above 12 during this work.Files
packages/flow/openadapt_flow/agent/ledger.py,ledger_demo.py,packages/agent/tests/test_ledger.py(22 tests).mcp.py(the ledger wraps dispatch),bridge.pyandguard_tools.py(aledgerattribute),cli.py(--no-ledger),console/save_approvals.py(a question shows its own text instead of "Save this?").packages/agent/README.md("Track a long job"), and a CAPABILITIES.md row. No newopenadapt-flowcommand, so "Every command, by capability" is unchanged.Not done
presentation.kind = "question", so Desktop can relabel it in a follow-up.Tests
packages/agent: 532 passed, 9 skipped, plus the 3 new regression tests; the README checks pass.packages/flow: console save-approval, save-fields, item-approval, guarded-save and capabilities-map tests: 63 passed. Ruff check and format are clean.🤖 Generated with Claude Code