Skip to content

Commit d2b7078

Browse files
authored
fix: improve agent startup and error messages in CLI (#2303)
1 parent 96da80c commit d2b7078

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

apps/agentstack-cli/src/agentstack_cli/commands/agent.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,11 @@ def search_path_match_providers(search_path: str, providers: list[Provider]) ->
433433

434434
def select_provider(search_path: str, providers: list[Provider]):
435435
provider_candidates = search_path_match_providers(search_path, providers)
436-
if len(provider_candidates) != 1:
437-
provider_candidates = [f" - {c}" for c in provider_candidates]
438-
remove_providers_detail = ":\n" + "\n".join(provider_candidates) if provider_candidates else ""
439-
raise ValueError(f"{len(provider_candidates)} matching agents{remove_providers_detail}")
436+
if len(provider_candidates) == 0:
437+
raise ValueError(f"No agents matched '{search_path}'")
438+
if len(provider_candidates) > 1:
439+
candidates_detail = "\n".join(f" - {c}" for c in provider_candidates)
440+
raise ValueError(f"Multiple agents matched '{search_path}':\n{candidates_detail}")
440441
[selected_provider] = provider_candidates.values()
441442
return selected_provider
442443

@@ -520,10 +521,10 @@ async def stream_logs(
520521
],
521522
):
522523
"""Stream agent provider logs. [Admin only]"""
523-
announce_server_action(f"Streaming logs for '{search_path}' from")
524524
async with configuration.use_platform_client():
525-
provider = select_provider(search_path, await Provider.list()).id
526-
async for message in Provider.stream_logs(provider):
525+
provider = select_provider(search_path, await Provider.list())
526+
announce_server_action(f"Streaming logs for '{provider.agent_card.name}' from")
527+
async for message in Provider.stream_logs(provider.id):
527528
print_log(message, ansi_mode=True)
528529

529530

apps/agentstack-server/src/agentstack_server/infrastructure/kubernetes/provider_deployment_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ async def stream_logs(self, *, provider_id: UUID, logs_container: LogsContainer)
265265
except kr8s.NotFoundError:
266266
...
267267
if not missing_logged:
268-
logs_container.add_stdout("Provider is not running, run a query to start it up...")
268+
logs_container.add_stdout("Agent is starting up...")
269269
missing_logged = True
270270
await asyncio.sleep(1)
271271

0 commit comments

Comments
 (0)