Skip to main content

straitjacket

Context and evidence sidecar for coding agents.

Keep your coding harness. Straitjacket runs alongside it, captures command output in a local artifact store, and returns a bounded, deterministic digest. The agent can search the complete output or retrieve a cited region without loading the whole log into its conversation.

Keep using your coding agent. Claude Code, Codex, and Antigravity remain supported. Straitjacket adds capture, bounded retrieval, and an optional verified edit workflow to the agent you choose; you keep its interface, models, login, and permissions. Any terminal-capable agent can use the ctx CLI.

The coding harness owns the model and tool loop. Straitjacket supplies capture, retrieval, and optional edit verification through CLI commands, MCP tools, and supported hooks. “Sidecar” describes this supporting role; no separate daemon or container is required. The package name remains ctx-harness.

Claude Code Codex Antigravity Hermes Oh My Pi OpenCode DeepSeek Harness

v0.41.0 · Python 3.11+ · package ctx-harness · command ctx · pre-1.0 · Apache-2.0

Start here · Choose a workflow · CLI reference · Documentation site

Capture your first result

From a repository with a test suite:

python -m pip install --upgrade ctx-harness
ctx run -- pytest -q

No host integration is required for this command. A failed test command remains a failed command. straitjacket changes how its evidence reaches the agent.

A large pytest result identifies failing tests and provides a run: address. Use the address and coordinates printed by your run:

ctx get run:<id>#stdout --lines 120:180
ctx search run:<id>#stdout "AssertionError"

<id> is a placeholder, not a checked-in sample you can retrieve. The stored artifact contains the complete captured stream. Retrieval is bounded too: a large request returns a smaller region with a continuation.

When that loop is useful, connect the host you already use:

ctx setup
ctx doctor

Setup preserves unrelated settings and reports the changes it makes. Installation, host setup, and removal.

Choose the work you want to improve

Job Use What you can inspect afterward
Diagnose a long test run, build, or log ctx run -- <command> Outcome, typed digest, complete stdout/stderr
Find the relevant symbol before reading files ctx map, ctx def, ctx refs Bounded structural views and source coordinates
Compare a failure with the next attempt ctx diff run:A run:B Changes in outcomes and evidence
Run a known sequence of checks ctx seq, ctx q Locally composed results with evidence addresses
Edit the source you actually observed ctx edit replace, ctx edit verify Sealed plan, apply receipt, checks tied to file hashes
Continue a task across workers ctx orchestrate, ctx task show Persisted task state, attempts, recovery, and budget records
Tell another harness something, between turns ctx relay watch, ctx relay signal Queued signals, delivery receipts, and what each harness has seen
Analyze selected evidence with a model ctx semantic prepare/run/resume Bounded partitions, citation validation, explicit budgets, and saved partial findings
Investigate and verify a repair ctx task prepare/run/resume One durable budget from evidence gathering through verified patch; workflow and SDK

Start with capture and retrieval. Add editing or orchestration when the task needs their contracts. See the verified edit loop for snapshot-based replacements, typed recovery, and prewalk handoffs.

If your harness owns its tools, use the provider-independent tool SDK: ToolSession.run/get/search/query returns bounded evidence with explicit command termination, supports async cancellation, and exports observed artifacts as a capsule. Other languages can use ctx run --json. These entry points require a build containing the change.

Semantic analysis is an explicit depth-one map over frozen evidence through a caller-configured model driver. Its findings are labeled inferences; complete processing does not establish complete evidence selection or a correct patch. Deterministic capture and retrieval never invoke it implicitly.

Why preserve the output outside the prompt?

A build log can outlive the decision it supported. Once pasted into the conversation, it can occupy context on every later turn. Truncation removes bytes the agent may need later; a free-form summary cannot provide the exact original evidence.

straitjacket retains those bytes and gives the prompt a smaller view. Typed profiles keep test identities, diagnostic locations, unusual log events, or JSON structure according to the output family. They declare omissions and provide retrieval addresses. There is no model call in the digest path.

Stored run:, blob:, and snapshot: handles identify immutable content while retained. Live repo: addresses can carry a content anchor: reads verify the span, relocate unchanged content, or refuse stale evidence.

Follow one command through the system.

Decide whether to use it

Your workload Starting choice
Large outputs early in a long investigation Capture them and retrieve only the evidence needed next
Repeated repository navigation Use structural queries; watch retrieval count as well as token volume
Small output in a short task Keep native execution; wrapping can add overhead
Need predictable local behavior without another model call Use the CLI directly
Need transparent interception Check the host matrix below before adopting

Measure task completion, total usage, elapsed time, and retrieval calls together. Compression alone does not establish a better coding outcome.

Evidence, including the losses

The repository publishes fixtures, harnesses, raw records, and negative results in evals/. Two mechanism tests establish the core behavior:

  • A deterministic 20,001-line log contains one quiet target at line 14,238 and two loud ERROR controls. Raw delivery uses 302,628 o200k_base tokens. straitjacket emits 531, retains the quiet target, and emits an address for the omitted region. This fixture checks address emission, not a retrieval round trip. See the field-needle receipt.
  • Across 1,920 repository-span resolutions after edits, anchored addresses relocated 1,452 times, verified in place twice, refused 466 times, and returned the wrong content zero times. See the anchor-drift receipt.
  • The task-ledger replay exercises persisted orchestration state across resume, typed recovery, and budget reconciliation. See the task-ledger receipt.

Those results test delivery and addressing. They do not prove that every agent task becomes cheaper or faster.

The live agent referee records the counterexample. On three small canary tasks, with one repeat per task, both native and contained arms solved 3/3, but the contained arm used more input tokens, cost more, and took longer. In one navigation-heavy dogfood run with a 40-turn cap, the native arm reproduced eight failing test nodes and the wrapped arm reproduced five. That comparison tests the full wrapper bundle, not containment alone, and its model field is unrecorded. The wrapped arm made 210 retrieval calls; without a retrieval ablation, those calls are a plausible contributor rather than a proven cause. See the agent-harness results.

The DeepSWE v1.1 receipt (eight Python tasks, haiku, 60-turn cap) is the sharper counterexample: under v0.39.0 the wrapped arm cost 27% more and read 36% more input than plain Claude for no gain, and the transcripts put both numbers on the wrapper — the observer proxy had switched Claude Code's deferred tool loading off, and small tool results came back as receipts. With those fixed the input gap is 3% and the wrapped arm passes more held-out tests. Run again with no turn cap under DeepSWE's own three-hour budget, no arm resolved a task outright with haiku and every session stopped on its own; ctx as the host (ctx agent, its own indexed retrieval tools, no turn-one pack) passed 25% more held-out tests than plain Claude at the same cost, in more turns — more turns did not mean more money. See the DeepSWE receipt.

That boundary matters. straitjacket is most useful when output is large, early, repeated, or likely to survive many turns. A short task with small, hot-cached results may be better left native. The target is matched task success with less context residency—not the highest compression ratio.

Host support

Entry point Current behavior
Direct ctx CLI Capture and retrieval without a host plugin
Claude Code Command rewriting and oversized-result substitution on supported hooks
Codex Implemented and contract-tested gates; live CLI receipt pending
Antigravity Deny recognized floods and supply a bounded replacement command; no output substitution
Hermes / Open Hermes Native argument rewriting and text-output replacement; active-profile plugin + MCP
Oh My Pi (omp) Native argument rewriting and text-output replacement; project plugin + MCP
OpenCode Native argument rewriting and text-output replacement; project plugin + MCP
DeepSeek Harness (dsh) Native gating and text-output replacement; sealed arguments require an explicit retry

ctx setup merges JSON where safe and refreshes ctx-managed blocks. For user-owned Codex TOML it prints a reviewed snippet rather than replacing the file. See host capabilities for exact coverage.

Set up Hermes, OMP, OpenCode, or DSH. These adapters have executable contract tests; live model-session receipts remain pending. They require a build containing this change.

All seven agents can use ACP orchestration with a configured endpoint and model: ctx setup --host opencode --acp --acp-model provider/model-id. ACP workers receive bounded retrieval and verified edit tools through MCP. Native hook coverage still depends on the agent's API; ACP does not expand it.

Boundaries

straitjacket is not:

  • a process sandbox—commands retain the invoking user's authority;
  • agent memory—it contains current tool evidence rather than choosing which old memories to recall;
  • a free-form summarizer—digests are deterministic, typed, and addressable;
  • a reason to wrap every command—the native path is often right for small work.

The local store contains captured command output as plaintext. Thirty days is the default GC eligibility horizon; artifacts remain until ctx gc runs. ctx gc --retention-days N can override the horizon, while pins and active checkpoint leases survive collection. Treat the store with the same care as the source and logs it captures. At-rest encryption is not implemented today.

The project is pre-1.0. Command and profile contracts may still change between minor releases.

Next step Guide
Install, configure, or remove a host integration Getting started
Apply and verify an observed edit Edit loop
Compare native, anchored, and prewalk strategies Paired evaluations
Tune budgets and retention Configuration
Resolve an error Troubleshooting
Understand modules or contribute Architecture, Contributing
Browse the full reference Documentation map, Changelog

Development

git clone https://github.com/vamsiramakrishnan/straitjacket.git
cd straitjacket
python -m pip install -e '.[dev]'
pytest

New mechanisms need deterministic output, explicit degradation, and a named evaluation gate. Follow CONTRIBUTING.md.

Metadata

Release files for ctx-harness 0.41.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ctx-harness 0.41.0
File Size Uploaded Provenance Actions
ctx_harness-0.41.0.tar.gz 885.2 kB With provenance Details for ctx_harness-0.41.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ctx-harness 0.41.0
File Interpreter ABI Platform Actions
ctx_harness-0.41.0-py3-none-any.whl Python 3 none any Details for ctx_harness-0.41.0-py3-none-any.whl

Total release size: 1.9 MB

Release files / ctx_harness-0.41.0.tar.gz

Download URL ctx_harness-0.41.0.tar.gz
Size 885.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8690c96259ab3feb7f399cc2b99e3571f9647825cdd4510c437300f59b23676d
BLAKE2b-256 checksum
How to use checksums
891fd64bb35cc55bb7b2bddca266d4b9d3b98ec453da386a5255778acc564905
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / ctx_harness-0.41.0-py3-none-any.whl

Download URL ctx_harness-0.41.0-py3-none-any.whl
Size 968.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c6b198ea0ece9edab1941d47276a980b0956c622b3535ee851a95ed16e7547a
BLAKE2b-256 checksum
How to use checksums
6d70ae0f97d27c8ef76b70773f969c061fbc46c0ff8e329414c2fed389aaa252
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for ctx-harness 0.41.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ctx_harness-0.41.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page