Public: anyone can read this; the crew can change it.
GET the models Talk offers me, and `model` on POST /api/v1/conversations and /conversation/messages #17916
Merged 22h 35m ago, live in production
Native clients can now ask which models Talk offers them and pick one when starting a conversation or sending a message. I ran only the suites that cover this change, not the whole suite, because scripts/fast.ts named 2814 files and was too broad. Those suites, the type check and the gate pass.
-
Reviews
Changes requested — before the latest pushNo high-severity security finding: the new route and both
modelinputs are authenticated,modelis length-checked, and an offered model is checked per person. The pull still needs these changes, all in one round:- The model switch happens before the message is accepted (
src/http/api/conversation_talk.ts, themodelblock in the messages handler). A message refused afterwards by the 12-a-minute limit, a bad file, a queue limit or anytalk()error still leaves the conversation switched, and the choice becomes the person's last choice. The builder flagged this and asked; the answer is yes: applysetChoiceonly aftertalk()accepts, or restore the previous choice on refusal. Validate withchoiceFromup front, as now, so a bad model still sends nothing. Also,openConversation(db, user.id)when no conversation is named may create a conversation as a side effect of a request that is then refused; resolve the target without creating, or switch after acceptance. - Missing tests, each of which would fail without the behaviour:
invalid_modelon/conversation/messages(a non-string or a 401-character string).model: ""switches back to the forge's own model on both POSTs.- A message refused for another reason (for example an empty
text) must not change the choice. This is the test for item 1. - The 'switches' test asserts only
status != 422; assert 202. - A
GET /api/v1/modelstest showingdefaultfollows the person's last choice (the docs and route detail promise it).
POST /api/v1/conversations: thesetChoiceresult is ignored after the conversation is created. Check it, or document why it cannot fail oncechoiceFrompassed.- Minor: the gate's note about the over-long comment in
src/core/model_choice.tsis the builder's own addition. Rewrap it rather than leave it for the nightly job.
The terminal door is covered by the existing
/modelpicker, soNo door:is accepted; the how-to is indocs/features/talk.md, not the README, which is right.ApprovedEarlier asks are met: a message the forge refuses now takes its model switch back (
switchModelreturnsundo, run whentalk()refuses). A conversation the request made is dropped, and the rate-limit test covers this.invalid_modelandmodel: ""are tested. The comments this pull did not write are restored. An unknown model is still 422 before anything is touched, the route needs a sign-in, andGET /api/v1/modelslists only what the person may use. Docs are indocs/features/talk.md, not the README, and the terminal's/modelpicker already usespickList, soNo door:is fair. Non-blocking: the over-long comment inmodel_choice.tsand the two near-duplicate test helpers can wait for the nightly rewrap. - The model switch happens before the message is accepted (
-
Checks
shipped production is serving it deploy a338207
-
History
- Merge main into torque/17912: regenerate src/generated/marks.ts 76752a5
- A cloud account can be a sealed, expiring, read-only view for a client (#17942) 046cfff
- Keep model_choice.ts's diff to the change: restore the comments this pull did not write (#17912) 58c0e66
- A refused message takes its model switch back; check and test the rest of the review (#17912) 4c3f087
- Name /api/v1/models in the untimed-route allowlist, like the conversation list 44c9c08
- Pages help a reader sift: icons, a type scale, settings in groups (#17940) 3000b02
- A command the box was not handed yet can be taken back (#17933) 703a520
- A game box that cannot lend says why, and new boxes can lend (#17941) 1d3c3d5
- The /search page keeps to the repository repo:owner/name names in q, as /api/… (#17932) c310a25
- Merge main into torque/17912: keep the model choice on create, main's unlimited start 3d2c418
- Talk: no conversation cap; archive old threads to backup storage and restore on open (#17930) f8f8b8f
- Merge main into torque/17912: regenerate src/generated/marks.ts 89c4d9c
- JSON for the home lanes, figures and slot graphs, with ETags (#17923) e16b19a
- Regenerate src/http/lazy_lists.ts (issue #17912) 7e1ed3b
- A crew run's page says how its model was fed, so a packed SubQ run compares with its explored run and with Claude (#17925) 52b26cd
- Infrastructure reads Azure: subscriptions, resources and costs (#17924) 4ceb81b
- Merge pull request #17921 from sold/azure-reads 509de83
- Azure reads serve #17922 570fb17
- Feed each model the way it works: packed context for long-window models like SubQ, tools for the rest (#17918) 898c0b9
- Merge main into torque/17912: keep model on the conversation routes with main's response/request schemas 95144bd
7 earlier comments
I regenerated src/http/lazy_lists.ts with bun scripts/lazy-lists.ts and pushed it; the forge's check on the pull is what confirms it. The check failed because that file was stale after the models route was added. The only change is one line, with no behaviour change.
I ran these locally and they pass:
- Stale-file test: the lazy-list generator test.
- Other named failures: the dead-code (unused-exports), duplicate-import, module-state and hollow tests.
- Gate and types: the gate's
--explainrun andbun x tsc --noEmit.
I ran the unused-exports test after pushing rather than before.
Nothing else on the branch changed. To try it, run bun scripts/lazy-lists.ts and confirm git status stays clean.
I merged main into the branch and pushed it. The only conflict was src/generated/marks.ts, which bun scripts/own-source.ts generates. I took main's side and regenerated it. It now carries both main's new api-v1-home mark and this pull's api-v1-models mark.
- Checks run:
bun x tsc --noEmitcame back clean.test/own-source.test.ts,test/api-models.test.tsandtest/talk-pin.test.tspass (15 tests). - Full suite not run:
scripts/fast.tsput the affected set at 2819 files, about 231 minutes, so I stopped the attempt. The forge's check runs the full suite on this push. - Gate:
bun scripts/gate.ts --fixchanged nothing. It still notes a comment over 100 columns insrc/core/model_choice.ts, which the nightly rewrap handles on main. It also flags two helpers intest/api-models.test.tsas near-duplicates of helpers intest/admin-words.test.tsandtest/talk-pin.test.ts; I left both alone.
I merged main into the branch again and pushed it. The only conflict was in src/http/api/conversation_talk.ts, in the POST /api/v1/conversations handler.
- Conflict: this pull set the chosen model on the new conversation and refused with
409 too_manywhen the start failed. Main madecreateConversationalways succeed and removed the too-many check. I kept this pull's model choice and dropped the409branch, since it can no longer happen. - Checks run:
bun x tsc --noEmitis clean.- The model, talk, conversation and
own-sourcetests pass: 994 pass, 50 skipped, 0 fail. The skips include the Talk layout test, which skips because no chromium starts here. bun scripts/gate.ts --fixchanged nothing. It still notes the over-long comment insrc/core/model_choice.tsand the two near-duplicate test helpers intest/api-models.test.ts, as before.
- Full suite not run: the forge's check runs it on this push.
I fixed one of the three failures and pushed; the other two I did not touch, and I couldn't confirm they were flakes.
- Fixed: "no GET route answers 200 without a session phase" failed because
GET /api/v1/modelsanswers 200 without asessiontiming phase. I added it to theUNTIMEDallowlist intest/route-timing-coverage.test.ts, next to/api/v1/conversations(same kind of read). That test file now passes. - Not fixed: "the pane's frame > draws a public app" and the "N+1: a pull's crew activity…" test. Nothing on this branch touches the Talk preview frame or crew activity, and the check log says both are green on main at
703a520. The frame test needs chromium, which doesn't start in my sandbox, so I couldn't run it. The N+1 test passed locally. I left both alone and expect them to pass on the re-run; if either fails again it will need a look.
All four items from the review are done and pushed. bun x tsc --noEmit is clean, and the model, talk, conversation, dead-code and process-state tests pass (1184 pass, 52 skip, 0 fail). I did not run the full suite; the forge's check does.
- Refused messages (1): I switched before
talk()rather than after, because the turn reads the conversation's model as it starts. Switching afterwards would run the first turn on the old model. InsteadswitchModelinsrc/core/model_choice.tsreturns anundo, and the messages route runs it whentalk()refuses (rate limit, queue, agent off).- What undo restores: the conversation's own choice, the person's last choice, and any conversation the request had to create when none was named.
- Kept messages: a kept message counts as accepted, so its switch stays.
- Unchanged: an unknown model still returns 422 before anything is touched.
- Docs:
docs/features/talk.mdnow says this.
- Tests (2): all five are in
test/api-models.test.ts.invalid_modelon the messages route (a number, and a 401-character string).model: ""switches back to the forge's own on both POSTs.- A message refused by the rate limit leaves the choice, the last choice and the conversation count as they were. I checked this fails with the undo disabled.
- The "switches" test now asserts 202.
GET /api/v1/modelsshowsdefaultfollowing the person's last choice.
- Empty
texttest: I did not write the empty-texttest you described, because badtext, files andduringare rejected before any switch happens, so it would pass with or without the fix. A bad file id has the same ordering and does not exercise it either. The rate-limit refusal is the real test for item 1. POST /api/v1/conversations(3):setChoicecannot refuse there, sincechoiceFromjust passed and the conversation is new and the person's own. I left a comment saying so rather than adding an unreachable branch.- Comments (4): all over-long comments in
src/core/model_choice.tsare rewrapped, and the gate now reports no comment over 100 columns. - Door: the commit says
No door:because the terminal's/modelpicker already covers it.
The gate failure is fixed and pushed. I had rewrapped comments in src/core/model_choice.ts that this pull didn't write, and the "diff is the change" rule refuses that. I restored all of them, so the file's diff against main is now only the import, ModelEntry, modelList and switchModel.
The gate now passes locally. Its remaining notes are the over-100-column comment in model_choice.ts and the two near-duplicate test helpers, none of them blocking. bun x tsc --noEmit is clean and test/api-models.test.ts passes (11 tests). I did not re-run the wider suite for this comment-only restore.
The review's item 4 asked me to rewrap the over-long comment. The gate won't allow that for comments the pull didn't write, so I left them for the nightly rewrap.
I merged main into the branch again and pushed it. The only conflict was src/generated/marks.ts. I took main's version and regenerated it with bun scripts/own-source.ts, so it now has both main's changes and this pull's api-v1-models mark.
bun x tsc --noEmit is clean. The gate reports nothing new: it still notes the over-long comment in src/core/model_choice.ts and the two near-duplicate test helpers in test/api-models.test.ts. The own-source, api-models, route-timing-coverage, conversation and talk tests pass (1003 pass, 50 skipped, 0 fail). The skips include tests that need a browser or network that the sandbox doesn't have. I did not run the full suite; the forge's check does that on this push.
Native clients can now ask which models Talk offers them and pick one when starting a conversation or sending a message. I ran only the suites that cover this change, not the whole suite, because
scripts/fast.tsnamed 2814 files and was too broad. Those suites, the type check and the gate pass. I did not runscripts/design-lint.ts(nosrc/web/change) orsimilar.ts, and the gate's note about duplicate test helpers is left as is.GET /api/v1/modelsreturns{ models: [{ id, name, connection, default }] }, in the order the Talk picker lists them.id; then each working connection's models.defaultmarks the one a new conversation starts on, which is the person's last choice while it is still offered.nameis the same plain name the picker shows.modelonPOST /api/v1/conversationsstarts the conversation on that model.modelonPOST /api/v1/conversation/messagesswitches the named (or open) conversation before the turn runs. It also becomes the person's last choice, as the page picker does.model_not_offered, and nothing is made or sent.modelthat is not a string of up to 400 characters is 422invalid_model.openapi.json, including the new route's tag, mark and generated index.modelListincore/model_choice.tsbuilds onstartingChoice,offers,plainNameandchoiceValue. The 422 bounds check reusesmodelRefusalfrombuild_input.ts, and the choice is made withchoiceFromandsetChoice, the same calls/api/v1/buildsuses.I did not add a terminal side:
pickListalready gives the terminal the same list and choice, so the commit saysNo door:. I added a section todocs/features/talk.md.A message that passes the model check but is then refused by the rate limit still leaves the conversation switched to that model. I judged that harmless; say if you want the switch to wait until the message is accepted.
To try it on the preview, call
GET /api/v1/modelswith a token. Then sendPOST /api/v1/conversations {"model": "<an id from that list>"}, and the samemodelonPOST /api/v1/conversation/messagesfor a conversation you own. The tests are intest/api-models.test.ts.🤖 Generated with Claude Code
Closes #17912