Skip to content

feat(tools): fuse deterministic command sequences into one tool call - #322

Open
raymondginger2018-sudo wants to merge 2 commits into
HKUDS:mainfrom
raymondginger2018-sudo:pr/run-steps-fusion
Open

raymondginger2018-sudo wants to merge 2 commits into
HKUDS:mainfrom
raymondginger2018-sudo:pr/run-steps-fusion

Conversation

@raymondginger2018-sudo

Copy link
Copy Markdown
Contributor

Summary

Fuses a deterministic sequence of commands into a single tool call.

Each model turn re-sends the whole prompt, so a five-command workflow costs five round
trips and five copies of the context. RunStepsTool lets the model declare the sequence
once; the harness executes it and returns one result carrying per-step evidence.

The interesting part is attribution. A fused sequence has to make it possible to say
exactly which step failed, what it printed, and that the steps after it were deliberately
not run — otherwise the harness has traded a retryable failure for an unattributable one.

Changes

  • core/harness/tools/run_steps.py (new): StepFusion engine + RunStepsTool
  • tests/test_run_steps.py (new): 47 cases — parsing, fusion, failure attribution, limits
  • core/harness/tools/__init__.py: export and register the tool (8 lines)

No existing behaviour is modified: the module is additive and the only touched file is the
tools package initializer.

Tests

pytest tests/test_run_steps.py                                     -> 47 passed
pytest tests/test_harness_policy.py tests/test_harness_approval.py -> 29 passed
ruff check --select E4,E7,E9,F                                     -> clean
ruff format --check                                                -> 3 files already formatted

Scope note

The full local CI replay (run-ci-jobs.sh preflight, 60–90 min on this machine) was not
run. Verification here is targeted: the new module's own suite plus the harness suites that
import the tools package. Upstream CI is the authoritative gate.

Each model turn re-sends the whole prompt, so a five-command workflow costs
five round trips and five copies of the context. RunStepsTool lets the model
declare the sequence once and get back one result carrying per-step evidence:
exit code, output, and an explicit skipped marker for steps that were
deliberately not run.

Attribution is the point. A fused sequence that cannot say which step failed
trades a retryable failure for an unattributable one.

- core/harness/tools/run_steps.py: StepFusion engine + RunStepsTool
- tests/test_run_steps.py: 47 cases (parsing, fusion, attribution, limits)
- core/harness/tools/__init__.py: export and register the tool
Registering RunStepsTool unconditionally changed the default tool set, which the
capability contract (tests/contract/test_default_capability_compatibility.py)
pins to an exact set - all three Python CI legs went red.

Fusion is now opt-in: the default session registers nothing, so the contract and
the default token cost are unchanged. Set DEEPCODE_RUN_STEPS=1 (true/yes/on) to
add it; when enabled it reuses the single bash instance.

The registration test now pins both halves: absent by default, present and
sharing bash when opted in.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant