[Bug]: CLI log warnings go to stdout and break `--json` output
Before submitting
- [x] I searched existing issues and did not find a duplicate.
- [x] I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Have a
t3CLI whose build is older than the database. The common way: the background service self-updates while~/.local/bin/t3stays on the old runtime (#14609). Here the service went 0.1.6 → 0.1.7 and the link stayed on 0.1.6. - Run any JSON command and keep stderr separate:
t3 thread show <thread-id> --messages 1 --json 2>/dev/null | head -c 300 - Pipe it into a JSON parser.
Expected behavior
With --json, stdout contains only the JSON document. Warnings and other logs go to stderr.
Actual behavior
The migration warning from apps/server/src/persistence/Migrations.ts is printed to stdout, in pretty format, before the JSON:
[00:11:54.904] WARN (#20): Database migration history diverges from this build; recorded migration ids are skipped, not reconciled by name. {
divergent: [
'77:RepairBooleanSettledOverride (unknown to this build)',
'78:DropOrchestrationEventCorrelationIndex (unknown to this build)',
'79:DelegatedRecoveryIndexes (unknown to this build)'
]
}
{"thread":{"threadId":"mcp:…", …}}
JSON.parse fails with Unexpected number in JSON at position 2. Our Telegram bridge uses thread send --wait --json and thread show --json. Right after the service self-updated, every turn failed this way: the agent replied in T3, but the bridge could not read the reply.
The CLI seems to log through the same Logger.consolePretty() as the server (apps/server/src/serverLogger.ts), and at least WARN lands on stdout. If so, any warning a CLI command logs would break --json the same way. A version mismatch is just the easiest way to trigger it.
Impact
Major degradation or frequent failure. Every scripted --json caller fails until the CLI link is fixed by hand, and the failure doesn't look related to the update.
Version or commit
CLI 0.1.6 against a 0.1.7 database (service self-updated). Logger and warning unchanged on main at 9e85538535.
Environment
macOS 15.7.8 (arm64 Mac mini), launchd service installed by t3 service install, Node 24.21 for the bridge.
Workaround
Repoint ~/.local/bin/t3 to the active runtime (~/.t3/runtime/versions/0.1.7/t3). On the client side, skip leading lines before the JSON document.
Not checked
Whether other CLI commands log anything else at the default level. Whether --log-level error hides this warning; it would be a workaround, not a fix.
Related: #14609 (the stale CLI link that triggers this), #26696, discussion #20439.