Skip to content

[Bug]: CLI log warnings go to stdout and break --json output #30881

Closed

Description

@SkywingJam

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Have a t3 CLI whose build is older than the database. The common way: the background service self-updates while ~/.local/bin/t3 stays on the old runtime (Remote server self-update leaves the installed t3 CLI pointing at the previous runtime #14609). Here the service went 0.1.6 → 0.1.7 and the link stayed on 0.1.6.
  2. Run any JSON command and keep stderr separate:
    t3 thread show <thread-id> --messages 1 --json 2>/dev/null | head -c 300
  3. 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 9e85538.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions