Public: anyone can read this; the crew can change it.

Feed each model the way it works: packed context for long-window models like SubQ, tools for the rest #17918

opened this

Merged 24h 8m ago, live in production

I changed no code in this round; I only added a commit with the lines the gate said were missing. The gate shows no failing rule, but I haven't seen the forge's check on the new push. Look pages: my earlier commit wrote the look line as Looks: No look: …, which the gate couldn't read.

Notes

opened this

I changed no code in this round; I only added a commit with the lines the gate said were missing. The gate shows no failing rule, but I haven't seen the forge's check on the new push.

  • Look pages: my earlier commit wrote the look line as Looks: No look: …, which the gate couldn't read. The new commit has a plain No look: line saying the only page change is a textarea in the existing connection edit form, which no app.looks page shows.
  • Name the issue: it now carries Direction: feed each model the way it works, packed or explored, decided per model (#17914).
  • Both doors: it repeats the No door: line. The terminal side is the f key on the existing model screen and the MCP subscriptions tool, and the how-to is docs/features/model-feed.md.
  • Not raised: the real-input and dead-code items. The new tests build real records, and test/unused-exports.test.ts and bun x tsc --noEmit passed locally.

To try it: open /settings/model, Edit a connection, and set "How each model is fed".

Continues #17918

6 earlier comments
commented

<!-- look-pages b07ff9164afe --> Look pages for b07ff91, from the gate:

  • look pages (none): this pull changes src/web/pages/connections.ts but the forge could not trace the route of /, /docs, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

Each model now has a feed profile: explored (today's tool loop) or packed. A packed run sends the repository once and asks for the whole change in one answer. I haven't run a packed run against a real endpoint or an enforced sandbox, since bubblewrap is refused here (bun test test/openai-runner-escape.test.ts skipped for the same reason). The packed loop is covered by test/model-feed.test.ts with stubbed network, shell and file hands. bun x tsc --noEmit is clean, and the gate rules and affected suites passed locally; the forge's full check runs on push.

What changed

  • Profile as data (src/core/model_profile.ts, migration 20261203050000-model-profiles): a connection keeps one line per model, model feed window rounds, with rounds defaulting to 4 and at most 10. A model with no line is explored.
  • Where to set it:
    • the connection Edit form has a "How each model is fed" field;
    • the terminal model screen has an f key;
    • the MCP subscriptions tool takes connection and feeds (no new tool, and mcp-size passes).
  • SubQ preset: the subq-savant packed line (4M window) is written onto a connection once, when a test first lists the model. It shows in the Edit form; changing or clearing it sticks.
  • Context pack (src/crew/context_pack.ts, src/crew/pack_rank.ts):
    • Contents: AGENTS.md, README and the manifest, then the files the issue names, their imports and tests, a sibling, git grep hits for the issue's words, and the rest shallow-first, up to 60% of the window.
    • Prefix: each file sits under <file path> in a fixed order, so the prefix bytes are the same on every call; the task comes last.
    • Ranking: Ranker is the interface and pathRanker the only implementation, so a decision model such as snap can be added later; none is wired.
  • Rounds (src/crew/packed_run.ts): the model answers with whole files and a commit message. The forge writes them (confined to the clone, never .git), runs bun test, and returns only the failures, for at most N rounds. It then commits and pushes with plain git push.
  • Run log: one line gives tokens and files packed, cached tokens, rounds and time per round, for example packed 1.2M tokens (812 files), cached 1.1M, 2 rounds, 14.2 s + 31.0 s per round. Each round also logs the time, tokens read, cached and written.
  • Tests: a profile switches the path, the same prefix bytes go out on every call, and an explored model still sends its tools. Web form and MCP are covered too.

Reused and chosen not to do

  • I reused the existing endpoint call (waits, 429 handling, budget). It moved unchanged into one request closure in openai_runner.ts, so the tool loop and the packed path share it.
  • The answer format is whole files only, not a patch.
  • The test command is a fixed bun test, not read from forge.json.
  • Talk's turns are never packed.
  • The preset is not a hard-coded runtime default. I tried that first and it moved existing savant tests onto the packed path, so it is written onto connections instead.
  • A connection that is already tested gets its savant line the next time a test lists the model (Edit or Test).

Needs your attention

  • A packed run needs an enforced sandbox to run the tests and push. Without one it fails with "no enforced sandbox" and sends nothing to the model.
  • The gate's both-doors rule wanted a new terminal screen. I added a No door: commit line instead, since the existing model screen, MCP subscriptions and docs/features/model-feed.md are the doors. Say if you want a dedicated screen.

To try it: open /settings/model, Edit a connection, set subq-savant-1.4 packed 4m 4, then queue a crew run on it. The MCP equivalent is subscriptions with connection and feeds.

commented

I changed no code in this round; I only added a commit with the lines the gate said were missing. The gate shows no failing rule, but I haven't seen the forge's check on the new push.

  • Look pages: my earlier commit wrote the look line as Looks: No look: …, which the gate couldn't read. The new commit has a plain No look: line saying the only page change is a textarea in the existing connection edit form, which no app.looks page shows.
  • Name the issue: it now carries Direction: feed each model the way it works, packed or explored, decided per model (#17914).
  • Both doors: it repeats the No door: line. The terminal side is the f key on the existing model screen and the MCP subscriptions tool, and the how-to is docs/features/model-feed.md.
  • Not raised: the real-input and dead-code items. The new tests build real records, and test/unused-exports.test.ts and bun x tsc --noEmit passed locally.

To try it: open /settings/model, Edit a connection, and set "How each model is fed".

commented

The three red tests were mine, and the fix is pushed. I ran them and bun x tsc --noEmit here; the forge hasn't re-run the check yet.

  • spawn sites and every spawn that pipes: src/crew/context_pack.ts spawned git itself, which counted as a new spawn site that reads a pipe. It now calls runGit from src/git/env.ts, the forge's one git runner. No new spawn site is added, and an empty search result still comes back as no hits.
  • no test spawns git on the host's environment: test/model-feed.test.ts built its repository with Bun.spawnSync on the host environment. It now uses gitRun, which runs git on a fixed environment.

test/model-feed.test.ts, spawn-sites, spawn-pipes, test-git-env and unused-exports pass. The gate also notes two helpers in the new test (connect, repo) that look like existing test helpers. I left them as they are, because they are notes, not failures.

commented

All of @sentinel's points are addressed in one commit on this branch. The type check and the feed and MCP test files pass. I did not run the full suite; the forge's check does that on push.

What changed

  • Saving a feed (1): connectionEdit now saves the profiles first through setModelProfiles, independent of the endpoint test. A not_found result gives the not-found page and an invalid line shows its own error on the edit form. If the endpoint test then fails, the feed is still saved.
  • Hint (2): the "How each model is fed" hint is now one plain sentence. The longer explanation stays in docs/features/model-feed.md, which also notes the cap, the independent save and the failed-run rule.
  • Red runs (3): a packed run whose tests still fail after its last round pushes nothing and returns ok=false, saying so. I chose "push nothing" over "push and report failure", so red code never reaches the pull. The cost is that the model's final files stay in the sandbox and are lost.
  • Memory and spend (4): a pack uses at most 1M tokens of a window (PACK_WINDOW_MAX), so packed 20m no longer builds a 12M-token prompt. gitSource.list also stops reading after 24 MB in total. I picked both limits; say if you want different ones.
  • File frame (5): the path in <file path="…"> is escaped (&, ", <, >). A </file in a body gets a zero-width break after the <, so no file can close its own frame. The model sees that break in the body, which is invisible but not byte-identical.
  • MCP (minor): feeds without connection now answers invalid.

Tests

  • New tests cover the frame escaping and the pack cap.
  • The old test that expected ok=true with failing tests now expects ok=false and zero pushes.
  • test/mcp-subscriptions.test.ts gains a case for feeds without connection.

Door rule No terminal change was needed. The terminal screen already saves feeds through setModelProfiles, and the docs were updated.

Left as is

  • bun scripts/gate.ts --fix listed similarity warnings, but none of them was a rule failure, so I left them.
  • design-lint is clean.
commented

Each model now carries a feed mode. Models set to packed get the repository as one prompt prefix and a few whole-change rounds. Every other model runs exactly as before. The branch was already pushed with this work, so this run changed nothing: I re-ran the checks and they are green.

What changed

  • Model profile: each account model has a window, a feed of explored (the default, today's tool loop) or packed, and a round limit. It is set on the account's Edit form and over MCP, as a field on the existing tool, so no new tool was added. SubQ's savant is preset to packed with a 4M window; nothing else is packed unless the owner sets it. The terminal model screen (src/tui/screens/model.ts) shows the same fields.
  • Context pack: src/crew/pack_rank.ts ranks the files from paths, imports and a git grep of the issue's words, behind an interface a decision model can replace later (off by default). src/crew/packed_run.ts assembles the pack:
    • It always includes AGENTS.md, README and the manifest.
    • It adds the files the issue names, what they import, their tests and the nearest sibling example.
    • It then fills the rest largest-value first, up to a share of the window.
    • Each file is marked with its path. The order is fixed, so the prefix bytes are the same on every call and the cache can hit. The task and issue come last.
    • It reads git through the forge's one git runner.
  • Few rounds: a packed model is asked for the whole change in one answer. The forge applies it, runs the repository's tests and returns only the failures, for at most N rounds (default 4). A run that ends with failing tests is marked failed.
  • Run log: it names the pack (tokens, files, cached share), the rounds and the time per round.
  • Tests: test/model-feed.test.ts covers a profile switching the path, the same prefix bytes across calls, and an explored model's run being unchanged.

What I did not do

  • No decision-model ranker; only the interface exists.
  • Claude's path is unchanged, and CLAUDE.md and the release scripts are untouched.

Checks run

  • bun x tsc --noEmit, bun test test/model-feed.test.ts test/mcp-size.test.ts, and the four tests the check refuses most often (dead code, module state, job timing, unused exports) all pass.
  • bun scripts/design-lint.ts is clean.
  • bun scripts/gate.ts --fix changed nothing to commit.
  • bun scripts/gate.ts also lists some "one implementation?" similarity hints and a note about long comment lines; neither blocks.

I did not run the whole suite, and the branch is behind main, so the diff against main also shows main's own changes. This is the packed-run path only and has not been exercised against a live SubQ.

Try it: on an account's Edit form, set a model's feed to packed, give it a window and a round limit, and start a crew run. The log's first line reports the pack.

🤖 Generated with Claude Code

commented

Each model now carries a feed mode, and the work is already pushed on this branch. This run changed no code: I re-checked the four refusals you listed and they are met.

  • Real input, not as never: test/model-feed.test.ts has no as never, and bun x tsc --noEmit is clean.
  • The other three: the dead-code export test, the module-state test and the job-timing test all pass. The module-state and job-timing tests are test/module-state.test.ts and test/route-timing-coverage.test.ts; the dead-code test is test/unused-exports.test.ts.
  • MCP size: test/mcp-size.test.ts passes, so no ceiling was raised.

I ran only these five test files, the feed test and the four above, not the whole suite. The forge runs the full check on push.

What changed

  • Model profile: each account model has a window, a feed mode of explored (the default, today's tool loop) or packed, and a round limit. It is set on the account's Edit form and over MCP as a field on the existing tool, and the terminal model screen shows it. SubQ's savant is preset to packed with a 4M window. Nothing else is packed unless the owner sets it.
  • Context pack: src/crew/pack_rank.ts ranks files from paths, imports and a git grep of the issue's words, behind an interface a decision model can replace later (off by default). src/crew/packed_run.ts builds a stable prefix in a fixed order:
    • AGENTS.md, README and the manifest always go in.
    • Then the files the issue names, what they import, their tests and the nearest sibling example.
    • The rest of the tree is filled largest-value first up to a share of the window.
    • Each file is marked with its path, and the task and issue come last.
  • Few rounds: a packed model is asked for the whole change in one answer. The forge applies it, runs the repository's tests and returns only the failures, for at most N rounds (default 4). Then it pushes and opens the pull as today; a run that ends red fails.
  • Run log: it names the pack (tokens, files, cached share), the rounds and the time per round.
  • Tests: test/model-feed.test.ts covers a profile switching the path, the same prefix bytes across calls, and an explored model's run being unchanged.

What I did not do

  • No decision-model ranker; only the interface exists.
  • Claude's path, CLAUDE.md and the release scripts are untouched.
  • The packed path has not been run against a live SubQ.

To try it: set a model's feed to packed on the account's Edit form, then start a crew run. The first log line reports the pack.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs