Skip to content

Fix interactive ao start crash when updating flat local config#2014

Open
yyovil wants to merge 1 commit into
AgentWrapper:mainfrom
yyovil:session/ao-76
Open

Fix interactive ao start crash when updating flat local config#2014
yyovil wants to merge 1 commit into
AgentWrapper:mainfrom
yyovil:session/ao-76

Conversation

@yyovil
Copy link
Copy Markdown
Contributor

@yyovil yyovil commented May 22, 2026

Problem

Interactive ao start --interactive on a flat local config crashed when writing orchestrator/worker overrides.

Fixes #2015

Root cause

start.ts assumed non-canonical config always had projects; interactive writes did rawConfig.projects[projectId] directly, causing Cannot read properties of undefined for flat YAML.

Fix

  • Add safe helper guards for raw config shape before mutating projects map.
  • Backfill missing projects and write through helper in both the interactive override path and start-new-orchestrator clone path.
  • Add regression test in packages/cli/__tests__/commands/start.test.ts for flat-local-config interactive override path.

Validation

  • pnpm --filter @aoagents/ao-cli test -- --run __tests__/commands/start.test.ts -t "writes interactive agent overrides"
  • pnpm --filter @aoagents/ao-cli test -- --run __tests__/commands/start.test.ts
  • pnpm --filter @aoagents/ao-cli typecheck

Copilot AI review requested due to automatic review settings May 22, 2026 12:36
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7182749328

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/cli/src/commands/start.ts Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 22, 2026

Greptile Summary

This PR fixes an ao start --interactive crash that occurred when writing agent overrides to a flat local config (a YAML file with top-level agent/runtime/workspace keys but no projects map). It adds helper guards (ensureRecord, ensureWrappedProjectConfigContainer, getProjectConfig) and a flat-config-aware branch in the interactive override path.

  • Interactive override path (agentOverride block): the flat-config case is now handled correctly — the else branch checks for the absence of a projects key and routes to writeProjectBehaviorConfig, which serialises through LocalProjectConfigSchema (passthrough), preserving the original flat keys without introducing a hybrid format.
  • startNewOrchestrator path: ensureWrappedProjectConfigContainer is used to initialise rawConfig.projects = {} when the source is flat, enabling collision-detection to proceed; however, no flat-specific write path is added here, so the resulting YAML still merges the new projects key with the original flat top-level keys.
  • Regression test: the new it block exercises the interactive override path on a flat config end-to-end and asserts that no projects key leaks into the written file.

Confidence Score: 4/5

Safe to merge for the interactive override crash fix; the startNewOrchestrator flat-config write path still persists a corrupted config.

The interactive override flat-config path is correctly fixed and the regression test validates it end-to-end. However, the startNewOrchestrator branch still writes a hybrid YAML when the source config is flat — it injects a projects map alongside the original top-level keys, and the original projectId is never populated in that map.

packages/cli/src/commands/start.ts — specifically the startNewOrchestrator block (lines ~1682–1715) where flat-config handling produces an incomplete multi-project YAML.

Important Files Changed

Filename Overview
packages/cli/src/commands/start.ts Interactive override flat-config path is correctly fixed with a guard branch and writeProjectBehaviorConfig. The startNewOrchestrator flat-config path still persists a hybrid YAML (flat keys + added projects map) with only the newId entry — no projectId entry — an unaddressed defect noted in a prior review.
packages/cli/tests/commands/start.test.ts Adds a complete regression test for the flat-config interactive override path; covers the correct code branch (non-canonical configPath, no projects key), properly restores env and TTY state in finally. No test for the startNewOrchestrator + flat-config path.

Reviews (2): Last reviewed commit: "fix(cli): guard interactive agent overri..." | Re-trigger Greptile

Comment thread packages/cli/src/commands/start.ts Outdated
Comment thread packages/cli/src/commands/start.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a crash in ao start --interactive when the discovered config is a flat (non-projects:) YAML by adding helper guards around raw config mutation and adding a regression test for the interactive override path.

Changes:

  • Added helper utilities in start.ts to ensure a projects container exists before writing per-project overrides.
  • Updated the “new orchestrator” and interactive override write paths to use the new helpers when mutating YAML.
  • Added a Vitest regression test covering interactive overrides starting from a flat local config file.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
packages/cli/src/commands/start.ts Adds raw-config shape helpers and uses them when writing interactive overrides / cloning “new orchestrator” config entries.
packages/cli/tests/commands/start.test.ts Adds regression coverage for interactive override persistence when starting from a flat local YAML config.

Comment thread packages/cli/src/commands/start.ts
Comment thread packages/cli/src/commands/start.ts Outdated
Comment thread packages/cli/src/commands/start.ts
Comment thread packages/cli/__tests__/commands/start.test.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interactive ao start crashes after selecting Grok/Codex agents

2 participants