ac4af582301a4e8a29245dbba767eba31334ddf9
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
985b9f1a0a |
gateway: Reasonix's session-context snapshot is the agent's (#3938)
keeyangyy (#3938) named their client: Reasonix 1.x, which sends no session header (it sets x-opencode-session on its OpenCode Go paths only) and opens every conversation on a snapshot it writes, the same bytes in every conversation started in one workspace while its memory and skills catalog don't change: {"role":"user","content":"<session-context version=\"1\">\nThis host-generated snapshot supersedes every earlier session-context snapshot.\n\n## Environment\n...\nDigest: sha256:<hex>\n</session-context>"}, {"role":"user","content":"the question the user actually typed"} userWords didn't know the block, so the commit before this one still hashed it alone: every conversation a workspace opened had one id, and under Stays = session each new one was kept on the account that answered the first. "<session-context" joins injected, beside Codex's "<environment_context>", with no closing ">" so that its version attribute matches. What asks userWords now passes over the snapshot as it passes over Codex's context: - the conversation's id runs from the snapshot through what the user typed (conversationOpening); - the turn count: [snapshot][typed] is turn 1, where it was 2 (turnIn); - a group's conversation key is the typed words, where it was the snapshot, the same for every conversation in the workspace (firstWords, in ruleKey and the affinity scope); - the turn before, which the classifier is told (turnBefore): on a conversation's first turn, and on each turn a new snapshot comes with, it was the snapshot, workspace and memory and all, as the user's previous message with no reply; now it is nothing on a first turn, and the user's words before the snapshot and the reply to them on a later one; - the classifier's question, Copilot's Auto and gatewayQuery take the user's last words before a snapshot sent after them, and the Claude subscription takes one after tool results as the agent's notice (agentNotice). A Reasonix conversation under way when this lands gets an id of its own on its next turn and is routed once as a new conversation, as the previous commit says of the others: it may move to another account, and its cache there starts over. The shape is the report's, which keeyangyy read from Reasonix's source (internal/sessioncontext) and didn't capture; its folder and digest are left out as they left them, and the tests use it as written. Not changed: the prompt breakdown (promptBuilder.userText) keeps its own list of Codex's blocks and still files the snapshot as a chat turn, so a Reasonix conversation's first turn shows there as two turns, where Codex's context adds none. That is left for a commit of its own. What was run (tree 71364f08, on origin/main |
||
|
|
a463b3ede2 |
gateway: the Codex app's page state is metadata, not the user's words (#3418)
What: <external_codex_apps_open_page> joins the injected leads in
prompt.go, beside the Codex app's <in-app-browser-context …>: a user
text that begins with it is what the agent put in as the user, not
words of theirs. Codex sends the open page's state as a user message
(<external_codex_apps_open_page>{"page_id":null}</external_codex_apps_open_page>),
and userWords took it for the user's. With pasted files and an empty
"My request" — which keeps only what follows the heading — it was the
only text left, so the classifier was asked about the page state alone
and an order group fell to its first member for the whole turn.
Everything that goes by userWords skips it alike now: no turn of its
own (turnIn, the prompt breakdown's turns), no words for the classifier
(userText, firstWords), nothing for a plugin's query or Copilot's Auto
to pick on, and — through agentNotice — a page state after a tool
result closes the result without being marked as the user's. The title
digest already skipped the marker (title_link.go); the two lists say
the same again. Whatever the marker wraps goes with it, JSON or not
(the check is the prefix); a "My request" that holds the user's words
still classifies on those alone.
Run: user_said_test.go grows the page state (three rows in
TestUserTextSkipsWhatTheAgentPutIn, codexPage in
TestUserSaysPastAReminderWithASource) and
TestIntentSkipsWhatTheCodexAppPutIn asks the group end to end. All
three are red on the parent (the classifier is asked once, with the
page state alone, and a rule matches on it) and green here, beside the
#1826 tests they extend; with prompt.go alone put back they are red
again. go test -tags nogui ./internal/gateway -count=1 green (357s);
gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and
GOOS=windows clean; go build ./... on darwin and the nogui CLI on
linux and windows.
Generated-by: GLM-5.3-Flash (ZCode)
Ported from ggbdpq's fork (hunt75-b-page-metadata, f8347ce50), as
written, onto origin/main
|
||
|
|
a1c30b5be9 |
gateway: a user message the agent wrote alone is no new turn, and routing asks about and keys on the user's own words (#1826)
What: one helper, userWords/userSaid in prompt.go, says what the user
said in a text: it drops <system-reminder …> blocks (now with a source=
attribute too, as ZCode sends) and any text that begins as an agent
writes for the model alone, and keeps only what follows the Codex app's
"## My request (for Codex):". The leads, beside agentsFor: Codex's
<environment_context>, <user_instructions>, <turn_aborted>,
<user_shell_command>, <subagent_notification>; Claude Code's and
ZCode's <task-notification>, <subagent-notification>, agent lists
("Available agent types …", "New agent types are now available …"),
TodoWrite and task-tool nudges, rewind notices; ZCode's
<plugin_reference>; the Codex app's <in-app-browser-context …>. Each
was taken from the clients' own code or a real transcript (Claude Code
2.1.296, ZCode.app's zcode.cjs, Codex CLI 0.162.1, ChatGPT.app).
Everything that asks "did the user say something" now goes by it:
- turnIn: a user message with nothing of the user's (and no image or
file) begins no turn. After an answer or a tool round it carries the
turn on (within), so the turn's rule and stick hold and the classifier
isn't asked; right after the user's own message it leaves that turn as
it began.
- userText: the classifier is asked about the last user message with
words of the user's, only those words (it was the last user message,
ZCode's agent list after the user's plugin question).
- firstWords (ruleKey and the affinity scope): the words of the first
user message that has any, so an instruction file or notice the agent
changes beside them no longer moves a conversation to a new key
mid-turn. A conversation with no words yet keys on its first message
as before.
- lastUserText (Copilot's Auto, a sibling): the same.
- userSays (the prompt breakdown's turns) is userWords != "".
Why: #1826 (ZCode) and @321sssrt-bit's comment (Codex): a TodoWrite
nudge was classified as a new, harder turn and sent a 常规 turn to the
复杂 member; a task notification or agent list re-classified the turn;
one ZCode session had three firstWords keys, and the turn that lost its
key fell to the group's first member.
Upgrade: a conversation whose first user message held injected text
gets a new key once (its words only), so its stick and turn rule are
looked up afresh on the first request after the upgrade.
Run: user_said_test.go (TestTurnInSkipsWhatTheAgentPutIn,
TestUserTextSkipsWhatTheAgentPutIn, TestFirstWordsAreWhatTheUserSaid,
TestLastUserTextSkipsWhatTheAgentPutIn,
TestIntentHoldsPastWhatTheAgentPutIn end to end through the server,
TestUserSaysPastAReminderWithASource) fails on the old code (all six
red with the five source files put back) and passes now; go test
./internal/gateway -count=1 green (323s); gofmt -l clean; go vet ./...
on darwin, GOOS=linux -tags nogui and GOOS=windows clean.
Not tried: a live ZCode, Claude Code or Codex session against a
group with intent rules; fixtures are the clients' literal strings.
Not done here: persisting turnRules beside the sticks (the issue's
idea 3); the classifier-failure fallback is the next commit.
|