Skip to content

feat(provider-zcode): attach to the zcode serve daemon - #1

Closed
panudetjt wants to merge 2 commits into
feat/provider-zcodefrom
t3/zcode-serve
Closed

panudetjt wants to merge 2 commits into
feat/provider-zcodefrom
t3/zcode-serve

Conversation

@panudetjt

Copy link
Copy Markdown
Owner

Stacked on pingdotgg#33684 (feat/provider-zcode). Follow-up to Discussion pingdotgg#34215; provider idea in pingdotgg#33685.

Problem

The ZCode provider spawns zcode app-server --stdio and plays the CLI's host half, so T3 Code has to read the CLI's encrypted credential store and mint project access tokens through Z.AI's business endpoints itself. zcode serve already owns that exchange in vendor code, on the same long-running surface the desktop app uses.

Fix

The provider now attaches to zcode serve instead of spawning a host per turn.

  • Reads ~/.zcode/server/run/status.json and the ingress token, requests a host capability, and connects to /ws/host. It starts zcode serve detached only when no daemon is healthy, and never owns or stops a shared daemon.
  • Maps channel calls onto the adapter's existing session surface (zcode-session.createSession, zcode-agent.resumeSession / sendPrompt / readSession / setMode / compactSession).
  • Streams the v4 conversation channel (subscribeConversationV4 plus onDynamicConversationFrame), filtered by conversation/<sessionId>.
  • Resolves permission and AskUserQuestion interactions through resolveInteraction.
  • Drops provider/updateAccountConfig, the interaction/requestProviderRuntimeHeaders handler, and zcodeRequestAuth.ts; the daemon owns credentials end to end.
  • Resume after a host restart now reads the advertised model list from session/subscribe, so the next send still carries the model's reasoning level (separate commit).
  • launchArgs is forwarded to zcode serve.

Testing

  • vp test run packages/provider-zcode apps/server/src/orchestration-v2/Adapters/ZcodeAdapterV2.test.ts — 70 passed
  • vp run check:changed — pass (typecheck 42 packages, lint, fmt, knip, tests)
  • Live against zcode 3.17.2 / provider v0.17.1 running as a shared user daemon (pid unchanged across the whole pass): provider status, GLM model picker, streaming turn, AskUserQuestion, steering, interrupt, /compact, and resume after a T3 server restart.
  • Found and fixed a resume bug during the pass: Reasoning level is required for account:.../GLM-5.3 after a restart. The adapter parsed settings.model instead of settings.model.available, so availableModels was empty on resume. Covered by the resume case in the adapter test, which fails without the fix.

Evidence

Walkthrough video (53s)

Provider attaches and authenticates GLM models from the daemon catalog
Provider status Model picker
AskUserQuestion round-trip Resumed thread after a T3 restart
Interaction Resume

Made with DeepSeek V4.1 Flash in T3 Code (OpenCode harness).

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL labels Nov 12, 2026
…wning app-server

The provider spawned `zcode app-server --stdio` per turn and minted its own
credentials, duplicating what the zcode CLI already owns and skipping the
user-level daemon.

T3 now attaches to `zcode serve`: it reads the daemon status file for the port
and ingress token, starts the launcher detached only when no daemon is running,
and streams the v4 conversation channel. Channel calls map onto the existing
adapter surface and interactions resolve through `resolveInteraction`.
Account-config pushing and the credential module are gone; the daemon owns the
exchange.
A resumed session advertises its models under snapshot.settings.model.available,
but subscribeSession parsed the model object itself, so availableModels stayed
empty. The next send then omitted reasoningLevel, which GLM-5.3 requires.

Parse the available list and cover the resumed send in the adapter test.
@panudetjt

Copy link
Copy Markdown
Owner Author

The Agent context budget check compares this head against main. Its only delta (mcpToolListJsonBytes 48131 → 48217) comes from the base branch, which predates the budget reduction on main; this PR does not touch agentContextBudget.json. It clears when pingdotgg#33684 next merges main.

@panudetjt

Copy link
Copy Markdown
Owner Author

Superseded by upstream pingdotgg#34713, which carries pingdotgg#33684 plus this migration on main. The branch stays for the stacked diff view (feat/provider-zcode base).

@panudetjt panudetjt closed this Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant