Commit graph

56 commits

Author SHA1 Message Date
Darkatse
48aa5c7242 refactor(agent): remove round and tool call budgets
Remove the profile limits, runtime counters, quota errors, and extra-round resume flow. Keep tool authorization stateless and give protocol drift recovery its own 20-attempt limit, reset on resume.

Migrate profiles to schema 5 and discard retired fields at the existing profile, draft, and checkpoint decoding boundaries. Route shared Session profile migration and persistence through AgentProfileService.

Validation: pnpm run check; focused profile and runtime tests; macOS profile migration, JSON save, export dialog, and old checkpoint reads.
2026-10-22 01:48:30 -04:00
Darkatse
974c1e0028 fix(agent): unify tool image storage and result projection
Store incoming images and rejection notes through one entry point, then project MCP results without duplicating structured text or describing image-only results as empty. Centralize stored image formats and file paths, reuse workspace text reads, and remove superseded identity checks.

Preserve Claude tool images and original text with or without current tool definitions. Route OpenAI-compatible tool media once and reject unsupported Gemini tool audio/video. Document capability, normalization and retention at their owning topics.

Validation: payload, gateway, runtime, MCP, image and Shell focused tests; Rust crate boundaries; pnpm run check.
2026-10-22 00:25:40 -04:00
Darkatse
8cba66db41 feat(agent): let tool results carry images
Normalize extension tool images once into workspace files, keep only references in history, and hydrate a request copy before model retries. Carry the admitted image capability through invocation binding and Session compaction, count retained images, and encode tool images in each provider format. Consolidate tool result construction and redact inline media by structure.

Validation: extension runtime contracts 4/4; agent tools 18/18; tool results 5/5; provider image encoding 4/4; HTTP classification and log redaction focused tests; extension JS contracts 3/3; TypeScript, frontend guards, lint and crate boundaries passed.
2026-10-21 22:21:05 -04:00
Darkatse
48f49349c8 fix(agent): name other tools by alias in built-in tool errors
Tool errors and run failures named task.return, workspace.finish and
workspace.commit by ID. An error about another tool now names it by
its alias; one about the tool just called says "this tool", so it has
no name to keep in step. ToolSystem.md states the rule.
2026-10-19 18:21:44 -04:00
Darkatse
4260e7293e feat(agent): support extension tools across chat and sessions
Register WebView tools through a dedicated provider with shared tool selection, naming, and result handling. Keep extension availability independent from saved profile selections.

Clarify model-facing feedback and consolidate behavioral tests and architecture documentation.
2026-09-22 00:55:32 -04:00
Darkatse
8d12ac646c docs(agent): describe unified workspace capabilities
Document skill mounts, prompt catalogs and migration boundaries. Retain the JavaScript capability and kit references while removing obsolete executor details.
2026-09-20 19:59:31 -04:00
Darkatse
8b7cf0c721 feat(agent): add JavaScript to the shared workspace shell
Unify Bashkit and QuickJS behind WorkspaceFs, retain the existing skill entry point during migration, and clarify Agent tool descriptions and errors.

Validation: pnpm run check.
2026-09-20 17:46:04 -04:00
Darkatse
edc66ea4c5 feat(agent): add Monty Python to workspace shell 2026-09-19 23:43:02 -04:00
Darkatse
5dc7d265cc feat(agent): add Bashkit workspace shell
Run shell commands and jq against the shared, scoped workspace. Integrate per-round automatic commits and cancellation that finishes active file writes before returning.
2026-09-19 21:44:54 -04:00
Darkatse
94601423e8 fix(agent): normalize tool arguments and recover invalid calls
Accept null and empty arguments as an empty object, and validate argument shape once before dispatch. Malformed calls consume their budget and return recoverable tool errors.

Normalize provider replay while preserving rejected input in audit storage. Include runtime and protocol regression coverage and the tool argument contract.

Validation: pnpm run check.
2026-09-13 06:56:02 -04:00
Darkatse
456821582e feat(agent): revise completed runs from frozen context
Start a new foreground invocation with fresh budgets while retaining the run context, tool snapshot, commit history, and workspace. Preserve the current output as a revision source and reuse unchanged persistent versions.
2026-09-08 03:09:03 -04:00
Darkatse
a996402de7 docs(agent): simplify and consolidate framework documentation 2026-09-06 20:53:05 -04:00
Darkatse
c3f8b3ee1b feat(mcp): add registration-level tool description overrides 2026-08-25 01:14:40 -04:00
Darkatse
7f03c2318f fix(agent): keep recoverable errors from terminating runs 2026-08-18 16:36:11 -04:00
Darkatse
605ae1b7fd refactor(agent): commit live workspace without checkpoints 2026-08-18 16:20:05 -04:00
Darkatse
a14070488c feat(agent): auto-commit text drafts before explicit commits 2026-08-13 01:16:57 -04:00
Darkatse
735409dff0 refactor(agent): present tool results as text and Markdown 2026-08-12 20:51:14 -04:00
Darkatse
4af6b0784a refactor(agent): hide internal tool result metadata from models 2026-08-12 18:50:48 -04:00
Darkatse
3a6c93a203 refactor(agent): standardize recoverable line-based reads 2026-08-12 17:49:30 -04:00
Darkatse
b78237c058 fix(search): preserve punctuation-only queries 2026-08-12 01:37:57 -04:00
Darkatse
206acdeaa7 feat(mcp): add tool execution to legacy generation 2026-08-10 00:19:16 -04:00
Darkatse
be58e1c3e6 feat(agent): add MCP tool execution 2026-08-09 19:40:11 -04:00
Darkatse
40159b499e refactor(agent): make canonical tool descriptors the source of truth 2026-08-04 20:07:20 -04:00
Darkatse
550916da57 feat(agent): gate canonical tool calls before dispatch 2026-08-04 15:37:36 -04:00
Darkatse
75b1e4129b feat(agent): bind tools to immutable invocation snapshots 2026-08-03 22:09:24 -04:00
Darkatse
4081bd214e feat(agent): add canonical tool descriptors and catalog 2026-07-31 19:01:38 -04:00
Darkatse
b529506534 refactor(agent): remove delegate-controlled subagent budgets #113 2026-06-29 13:41:25 -04:00
Darkatse
097fa69096 feat(agent): add multi-agent handoff control transfer 2026-06-06 01:19:27 +08:00
Darkatse
3f59ceb792 refactor(agent): replace subagent workspace views with shared paths 2026-05-31 17:35:06 +08:00
Darkatse
6ccee166ac fix(agent): keep recovering direct-output drift until max rounds 2026-05-31 01:15:23 +08:00
Darkatse
8800b353ff fix(agent): allow workspace patches after partial reads 2026-05-30 22:11:37 +08:00
Darkatse
d246ac2ef8 fix(agent): remove implicit workspace result hydration 2026-05-30 21:50:04 +08:00
Darkatse
3424bb6509 feat(agent): add append mode for workspace file writes 2026-05-30 21:27:09 +08:00
Darkatse
22f3790b27 feat(agent): add opt-in dice roll tool 2026-05-30 19:59:08 +08:00
Darkatse
9a810d5d15 refactor(agent): use profile-scoped SubAgent workspace permissions 2026-05-29 03:12:44 +08:00
Darkatse
c369a64d5f feat(agent): add concurrent background worker scheduling for SubAgents 2026-05-29 00:57:19 +08:00
Darkatse
4d9e210bb6 feat(agent): add first-stage return-mode SubAgent runtime 2026-05-28 02:30:29 +08:00
Darkatse
ab726462d0 fix(agent): use text metrics and typed tool result payloads 2026-05-22 23:15:54 +08:00
Darkatse
2750b58370 fix(agent): capture direct outputs and update default prompt 2026-05-21 00:17:59 +08:00
Darkatse
b34062aa70 fix(agent): preserve committed output as partial success 2026-05-20 00:16:10 +08:00
Darkatse
b68e962f24 fix(agent): align drift recovery and rollback semantics 2026-05-19 23:00:07 +08:00
yhny1001
73a22d743a feat(agent): soft drift recovery + strengthen workspace.commit hint (#64)
Background
----------
Issue surfaced in production: model uses tools correctly through the
full pipeline (write_file → commit), then on the round expected to call
workspace_finish, replies with the full content as plain assistant text
instead. The committed message survives but the run fails with
`model.tool_call_required`, leaving an orphaned chat message and the UI
locked. PR #62 (issue #55) added rollback signalling so the host can
unwind cleanly, but the model's work is still discarded.

Two complementary fixes:

1. Strengthen `workspace.commit`'s tool result string with an explicit
   "REQUIRED NEXT STEP: call workspace_finish" reminder + a
   `nextRequiredTool` field in structured payload. This is the highest
   attention real-estate in the prompt (last tool result the model sees
   before the next turn) and costs essentially nothing.

2. Soft drift recovery: when the model returns 0 tool calls, give it
   ONE corrective nudge instead of failing immediately. We push the
   model's drifted text into history (so it owns what it said) and
   append a synthetic `user` reminder that distinguishes the post-commit
   case (commit will be rolled back) from the no-commit case (every
   turn must use a tool). If the model recovers (any tool call) the
   run continues normally; if it drifts again, we fall through to the
   existing #55 path (rollback + `userRetryable=true`).

   Hard cap of 1 attempt per run via `DRIFT_RECOVERY_MAX_ATTEMPTS`
   prevents token-bombing on stubborn drifters. Multi-turn pattern
   verified against Anthropic + OpenAI docs as API-compatible (no
   role-alternation constraint after no-tool-use turn).

Backward compatibility
----------------------
- Failed recovery falls through to existing #55 code path: same
  `model.tool_call_required` error, same `run_rollback_targets` event,
  same `userRetryable=true`. No frontend changes required for the
  failure case.
- New `drift_recovery_attempted` event is additive; old hosts ignore.
- Existing #55 drift test extended to include the recovery attempt
  before falling through to rollback.

Tests
-----
- `foreground_run_emits_rollback_targets_on_tool_call_required_drift`:
  updated to assert exactly one `drift_recovery_attempted` precedes the
  rollback when the model drifts twice in a row.
- `foreground_run_recovers_from_post_commit_drift_with_nudge`: new —
  model drifts after commit, gets nudged, complies with finish; run
  completes, no rollback, commit preserved. Also asserts the nudge text
  reaches the model verbatim.
- `foreground_run_recovers_from_no_commit_drift_with_nudge`: new —
  model drifts on turn 1, gets nudged, completes the full pipeline.

601 lib tests passing.

Docs
----
- `RunEventJournal.md`: documents `drift_recovery_attempted` event +
  recovery flow.
- `ToolSystem.md`: spells out the soft-recovery contract and which
  drift codes do/don't get the second chance.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-19 19:08:20 +08:00
yhny1001
fb238538ae fix(agent): emit run_rollback_targets + userRetryable on instruction drift (#55)
When the model deviated from the tool contract after committing chat
artifacts (e.g. answered with plain text instead of calling
`workspace_finish`), the run failed with `model.tool_call_required` /
`agent.tool_after_finish` / `agent.max_tool_rounds_exceeded`, but the
already-committed messages were left orphaned in chat and the UI had no
signal to offer a Retry path.

Loop runner now tracks each `AgentToolEffect::ChatCommitted` during a
run. When the run later enters a drift state, it emits a
`run_rollback_targets` warn event BEFORE `run_failed`, listing the
`{ path, mode, messageId, round }` of every commit the host UI needs to
roll back.

`run_failed` payload gains a `userRetryable: bool` flag:
- `retryable=true` (transient / rate-limited) implies `userRetryable=true`.
- Otherwise drift codes (`model.tool_call_required`,
  `agent.tool_after_finish`, `agent.max_tool_rounds_exceeded`) are
  `userRetryable=true` while remaining auto-non-retryable, so the UI can
  surface a manual Retry button after performing the rollback. Policy /
  validation errors stay `userRetryable=false`.

`workspace_commit` description tightened to spell out the
"commit -> finish in the same or next turn, never plain text" contract.

Docs:
- `docs/Agent/RunEventJournal.md`: new `run_rollback_targets` event,
  expanded `run_failed` payload schema with `userRetryable` semantics.
- `docs/Agent/ToolSystem.md`: documents the
  `workspace.path_is_directory` business error and the commit/finish
  drift contract so the tool-system docs stay in sync.

Tests: integration test
`foreground_run_emits_rollback_targets_on_tool_call_required_drift`
drives a mock gateway to commit then drift, asserting that the
rollback event lists the committed message and that the run fails with
`userRetryable=true`. Extended `error_payload` unit tests cover all
three drift codes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-18 20:03:59 +08:00
Darkatse
bb9b1d7c38 fix(agent): shorten tool audit file names 2026-05-05 18:34:40 -04:00
Darkatse
cdedf4154c fix(agent): hash tool audit file names 2026-05-05 16:42:16 -04:00
Darkatse
9d7ad56480 feat(agent): add progressive World Info disclosure
Change worldinfo.read_activated to list activated entry refs by default
and require explicit ref-based reads for entry content.

- replace bulk World Info content output with index/content modes
- add per-entry character range reads and recoverable ref/range errors
- update Agent prompt guidance, tool schema, docs, and runtime tests
2026-05-04 22:22:58 -04:00
Darkatse
90e612b1a4 feat(agent): add file search and ranged reads
- Add workspace.search_files and skill.search so agents can discover relevant
content in visible workspace files and installed Skills before reading.

- Extend workspace.read_file and skill.read with line and character range reads
for large files, and wire the new capabilities through tool specs, dispatcher,
profile defaults, prompt hints, host Skill APIs, docs, and tests.
2026-05-04 00:44:01 -04:00
Darkatse
8838af1f99 feat(agent): split workspace commit from run finish
Introduce workspace.commit as the explicit chat publication step while
keeping workspace.finish scoped to run completion.

- add foreground/background run presentation semantics
- route chat commits through a host bridge backed by saveReply()
- support default replace commits and append commits on one message floor
- require foreground runs to commit before finish
- remove the old prepare/finalize commit API path
- update Agent docs, types, and runtime tests
2026-05-03 23:07:07 -04:00
Darkatse
4fde5e4981 feat(agent): Add Agent Profile foundation
- add Agent Profile domain models, file repository, resolver, and management commands
- resolve profiles before run creation and persist resolved_profile.json in run inputs
- drive tools, skills, workspace roots, output artifacts, rounds, and budgets from profiles
- support agentSystemPrompt replacement and model-facing tool description overrides
- enforce profile tool policy and skill read budgets at runtime
2026-05-03 21:57:21 -04:00
Darkatse
f990f778c9 feat(agent): Add Agent Skill management and read tools
- Add file-backed Skill storage with import preview, install, export, source refs, and safe file reads
- Expose the Skill Host API and embedded Preset/Character Skill import prompts
- Register skill.list and skill.read in the Agent tool loop
- Cover archive roundtrips, source cleanup, symlink safety, and API contracts
- Refresh Agent docs around the current Skill capability boundary
2026-05-02 22:10:49 -04:00