fix(terminal-service): gracefully handle missing agent profiles in CAO store#186
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #186 +/- ##
=======================================
Coverage ? 91.71%
=======================================
Files ? 55
Lines ? 4394
Branches ? 0
=======================================
Hits ? 4030
Misses ? 364
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4ede555 to
2c78115
Compare
|
@anilkmr-a2z thanks for the great work. just some minor comments: 1 — Unrelated
|
…O store
load_agent_profile() raises FileNotFoundError for agents whose profiles
only exist as .json files (e.g. ~/.kiro/agents/my-agent.json). The call
in terminal_service.create_terminal() was unguarded, causing terminal
creation to fail with:
Failed to create terminal: Agent profile not found: my-agent
This was introduced in awslabs#145 when profile loading was hoisted to a top-level
call outside the allowed_tools block, but the FileNotFoundError guard
was not moved with it.
Wrap load_agent_profile() in try/except FileNotFoundError and gate
allowed_tools resolution on profile is not None. For kiro_cli, the
profile is resolved natively by kiro-cli itself — CAO not finding it in
its own store is expected and non-fatal.
This matches the documented behavior in docs/kiro-cli.md:
If the agent is not found, CAO gracefully falls back — kiro-cli resolves
.json profiles natively
71f308a to
9c95b1e
Compare
Good catch. Fixed these. |
haofeif
left a comment
There was a problem hiding this comment.
Thanks @anilkmr-a2z looks great to me
…O store (awslabs#186) load_agent_profile() raises FileNotFoundError for agents whose profiles only exist as .json files (e.g. ~/.kiro/agents/my-agent.json). The call in terminal_service.create_terminal() was unguarded, causing terminal creation to fail with: Failed to create terminal: Agent profile not found: my-agent This was introduced in awslabs#145 when profile loading was hoisted to a top-level call outside the allowed_tools block, but the FileNotFoundError guard was not moved with it. Wrap load_agent_profile() in try/except FileNotFoundError and gate allowed_tools resolution on profile is not None. For kiro_cli, the profile is resolved natively by kiro-cli itself — CAO not finding it in its own store is expected and non-fatal. This matches the documented behavior in docs/kiro-cli.md: If the agent is not found, CAO gracefully falls back — kiro-cli resolves .json profiles natively Co-authored-by: haofeif <56006724+haofeif@users.noreply.github.com> (cherry picked from commit 23075f3)
Problem
load_agent_profile()raisesFileNotFoundErrorfor agents whose profilesonly exist as
.jsonfiles (e.g.~/.kiro/agents/my-agent.json). The callin
terminal_service.create_terminal()was unguarded, causing terminalcreation to fail with:
Failed to create terminal: Agent profile not found: my-agent
This was introduced in #145 when profile loading was hoisted to a top-level
call outside the
allowed_toolsblock, but theFileNotFoundErrorguardwas not moved with it.
Fix
Wrap
load_agent_profile()intry/except FileNotFoundErrorand gateallowed_toolsresolution onprofile is not None. Forkiro_cli, theprofile is resolved natively by
kiro-cliitself — CAO not finding it inits own store is expected and non-fatal.
This matches the documented behavior in
docs/kiro-cli.md:Changes
services/terminal_service.py: guardload_agent_profile()calltest/cli/commands/test_launch.py: update test to reflect that CWD isalways passed (working-directory inheritance behavior)