Bug: --print / -p non-interactive mode hangs with TTY and fails with third-party APIs
Summary
The --print (-p) non-interactive flag has two critical bugs that make it unusable:
- Hangs forever when stdin is a TTY (normal terminal) — never exits
- 400 error with third-party APIs — sends
role: "developer" which most OpenAI-compatible APIs reject
Environment
|
|
| Kimchi version |
0.1.72 |
| OS |
Windows 11 |
| Shell |
PowerShell / Git Bash |
| Install method |
kimchi update (binary) |
| Config |
Multi-model with 7 modelRoles configured |
Reproduction: Bug #1 — TTY Hang
# This hangs FOREVER (no exit, no output beyond config warnings):
kimchi -p --no-session "Say hello"
# Expected: process prompt, print response, exit
# Actual: hangs indefinitely, must Ctrl+C
Workaround (forces non-TTY):
kimchi -p --no-session "Say hello" < /dev/null 2>&1
# This EXITS, revealing the underlying API error
Root cause: When stdin is a TTY, kimchi initializes the full interactive TUI even in -p mode. The --mode rpc output shows it gets stuck at:
{"method":"setStatus","statusKey":"permissions-mode","statusText":"default"}
{"method":"setStatus","statusKey":"active-tags","statusText":"phase: explore"}
After this — no further output. Agent is waiting for user interaction that never comes.
Flags tested that DON'T fix it:
--yolo → still hangs
--auto → still hangs
--plan → still hangs
--no-session → still hangs
--mode json → still hangs
--mode rpc → shows init messages then hangs
Reproduction: Bug #2 — 400 developer Role Error
# Non-TTY mode reveals the underlying API error:
kimchi -p --no-session "Say hello" < /dev/null 2>&1
# Output:
# Error: 400 developer is not one of ['system', 'assistant', 'user', 'tool', 'function']
# EXIT: 1
Session log evidence (~/.config/kimchi/harness/sessions/.../...jsonl):
"errorMessage":"400 developer is not one of ['system', 'assistant', 'user', 'tool', 'function']"
This error repeats across ALL retries (3 retries × multiple turns) before the exploration guard triggers.
Root cause: Kimchi's harness sends system-level messages with role: "developer" (OpenAI's newer role for o1/gpt-4o+ models). However, most third-party OpenAI-compatible APIs only accept ['system', 'assistant', 'user', 'tool', 'function'] and reject developer.
Providers tested — ALL failed with developer role:
| Provider |
Model |
Error |
| freetokenfaucet2 |
qwen3.7-plus |
400 developer is not one of [...] |
| aiand |
zai-org/glm-5.2 |
403 Forbidden (or 400) |
| aiand2 |
deepseek-v4-pro |
403 Forbidden |
| hcnsec |
DeepSeek-V4-Flash |
Timeout |
| opnegateway |
tencent/hy3:free |
Error |
| bynara1 |
tencent-hy3 |
Error |
| cccctoken |
gpt-5.5 |
Error |
What DOES Work
Only kimchi-dev provider succeeds:
kimchi -p --provider kimchi-dev --model deepseek-v4-flash --no-session "Say hello" < /dev/null
# Output: "Hello! How can I help you today?"
# EXIT: 0
Confirmed working models on kimchi-dev: deepseek-v4-flash, minimax-m3, kimi-k2.7
Current Multi-Model Config (failing)
{
"modelRoles": {
"orchestrator": "freetokenfaucet2/qwen3.7-plus",
"planner": "opnegateway/tencent/hy3:free",
"builder": "aiand2/zai-org/glm-5.2",
"reviewer": "aiand/zai-org/glm-5.2",
"explorer": "aiand2/deepseek-ai/deepseek-v4-pro",
"researcher": "bynara1/tencent-hy3",
"compactor": "aiand/zai-org/glm-5.2"
}
}
All 7 roles use third-party APIs → all fail with 400 developer error.
Expected Behavior
-p should NOT initialize TUI when stdin is a TTY — it should run in true non-interactive/headless mode and exit after processing
-p should work with third-party APIs — either use role: "system" instead of role: "developer", or auto-detect and fall back
Suggested Fixes
Fix 1: TTY detection in -p mode
When -p flag is set, force non-interactive/headless code path regardless of TTY detection.
Fix 2: developer → system role fallback
Either change the harness to use role: "system" by default (all APIs support this), or detect the 400 developer error and retry with role: "system".
Fix 3: Better error surface in non-interactive mode
When -p mode encounters an API error after all retries, print the error to stderr and exit with non-zero code, rather than entering the interactive retry/session loop.
Note on developer role
The developer role is an OpenAI-specific feature for newer models (o1, gpt-4o, etc.). Most open-source model APIs and third-party proxies use pydantic validation that strictly checks for ['system', 'assistant', 'user', 'tool', 'function']. Using role: "system" would be universally compatible while still functioning identically on OpenAI's API (which accepts both).
Bug:
--print/-pnon-interactive mode hangs with TTY and fails with third-party APIsSummary
The
--print(-p) non-interactive flag has two critical bugs that make it unusable:role: "developer"which most OpenAI-compatible APIs rejectEnvironment
0.1.72kimchi update(binary)Reproduction: Bug #1 — TTY Hang
Workaround (forces non-TTY):
Root cause: When stdin is a TTY,
kimchiinitializes the full interactive TUI even in-pmode. The--mode rpcoutput shows it gets stuck at:{"method":"setStatus","statusKey":"permissions-mode","statusText":"default"} {"method":"setStatus","statusKey":"active-tags","statusText":"phase: explore"}After this — no further output. Agent is waiting for user interaction that never comes.
Flags tested that DON'T fix it:
--yolo→ still hangs--auto→ still hangs--plan→ still hangs--no-session→ still hangs--mode json→ still hangs--mode rpc→ shows init messages then hangsReproduction: Bug #2 —
400 developerRole ErrorSession log evidence (
~/.config/kimchi/harness/sessions/.../...jsonl):This error repeats across ALL retries (3 retries × multiple turns) before the exploration guard triggers.
Root cause: Kimchi's harness sends system-level messages with
role: "developer"(OpenAI's newer role for o1/gpt-4o+ models). However, most third-party OpenAI-compatible APIs only accept['system', 'assistant', 'user', 'tool', 'function']and rejectdeveloper.Providers tested — ALL failed with
developerrole:400 developer is not one of [...]403 Forbidden(or 400)403 ForbiddenWhat DOES Work
Only
kimchi-devprovider succeeds:Confirmed working models on
kimchi-dev:deepseek-v4-flash,minimax-m3,kimi-k2.7Current Multi-Model Config (failing)
{ "modelRoles": { "orchestrator": "freetokenfaucet2/qwen3.7-plus", "planner": "opnegateway/tencent/hy3:free", "builder": "aiand2/zai-org/glm-5.2", "reviewer": "aiand/zai-org/glm-5.2", "explorer": "aiand2/deepseek-ai/deepseek-v4-pro", "researcher": "bynara1/tencent-hy3", "compactor": "aiand/zai-org/glm-5.2" } }All 7 roles use third-party APIs → all fail with
400 developererror.Expected Behavior
-pshould NOT initialize TUI when stdin is a TTY — it should run in true non-interactive/headless mode and exit after processing-pshould work with third-party APIs — either userole: "system"instead ofrole: "developer", or auto-detect and fall backSuggested Fixes
Fix 1: TTY detection in
-pmodeWhen
-pflag is set, force non-interactive/headless code path regardless of TTY detection.Fix 2:
developer→systemrole fallbackEither change the harness to use
role: "system"by default (all APIs support this), or detect the400 developererror and retry withrole: "system".Fix 3: Better error surface in non-interactive mode
When
-pmode encounters an API error after all retries, print the error to stderr and exit with non-zero code, rather than entering the interactive retry/session loop.Note on
developerroleThe
developerrole is an OpenAI-specific feature for newer models (o1, gpt-4o, etc.). Most open-source model APIs and third-party proxies use pydantic validation that strictly checks for['system', 'assistant', 'user', 'tool', 'function']. Usingrole: "system"would be universally compatible while still functioning identically on OpenAI's API (which accepts both).