Repository navigation
fix(cli): run JSON crews headless when there is no terminal - #8239
Conversation
`crewai run` on a JSON crew opened the Textual run screen unless CREWAI_DMN was set. Without an interactive terminal (a coding agent's shell, CI, piped input) the screen stayed open after the crew finished, so the command never exited. It now opens only when is_interactive() is true, the convention declarative flows already follow; otherwise the crew runs on plain output and the command exits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Strix Security ReviewNo security issues found. Review summaryReviewed the full diff for PR #8239. The change makes Updated for Reviewed by Strix |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
iris-clawd
left a comment
There was a problem hiding this comment.
The early branch makes the unsafe headless route unable to reach Textual while preserving the interactive and DMN cases.
Not holding this for it, but worth a ticket so it is not forgotten: This changes the observable default behavior of a public CLI command: non-TTY JSON runs now select plain execution instead of the TUI. The two paths are not presentation-only: the TUI path applies _prepare_json_crew_for_tui, changing verbosity and LLM streaming, while the headless path does not.
crewai runon a JSON crew, the defaultcrewai create crewproject, always opened the interactive run screen unlessCREWAI_DMNwas set. Without a terminal (a coding agent's shell, CI, piped input) the screen stayed open after the crew finished, so the command never exited. JSON crews now follow the rule declarative flows already use: the screen opens only in an interactive terminal, and otherwise the crew runs on plain output and the command exits._run_json_crewgates the screen onis_interactive()(stdin is a terminal andCREWAI_DMNis unset) instead of onCREWAI_DMNalone.CREWAI_DMNstill forces the plain run.crewai run < /dev/nullon a scaffolded JSON crew exits 0 in 28 s, and hangs until killed on main.crewai run, or read results withcrewai log-tasks-outputs._run_conversational_flow_tui) still open the chat screen without a terminal check. Needs a ticket.🤖 Generated with Claude Code
Note
Low Risk
CLI run-mode gating only; no changes to crew execution, auth, or data handling beyond when the TUI starts.
Overview
Fixes
crewai runon JSON crews so the command exits in non-interactive environments (coding agents, CI, piped stdin) instead of leaving the run TUI open after kickoff finishes._run_json_crewnow skips the TUI whenis_interactive()is false (no TTY orCREWAI_DMNset) and uses the plain_run_json_crew_without_tuipath; interactive terminals still get the run screen, with inputs resolved as fully interactive on that path. Theis_dmn_mode_enabledimport from this module is removed in favor of the sharedis_interactive()helper.Tests mock
stdin.isattyfor existing TUI cases and add coverage for headless vs TUI selection.Reviewed by Cursor Bugbot for commit caa4173. Bugbot is set up for automated code reviews on this repo. Configure here.