Runs an agent in query/automated mode.
(
*,
agent_parent_dir: str,
agent_folder_name: str,
query: Optional[str] = None,
state_str: Optional[str] = None,
session_id: Optional[str] = None,
replay: Optional[str] = None,
timeout: Optional[str] = None,
in_memory: bool = False,
jsonl: bool = False,
session_service_uri: Optional[str] = None,
artifact_service_uri: Optional[str] = None,
memory_service_uri: Optional[str] = None,
use_local_storage: bool = True,
default_llm_model: Optional[str] = None,
)
| 544 | |
| 545 | |
| 546 | async def run_once_cli( |
| 547 | *, |
| 548 | agent_parent_dir: str, |
| 549 | agent_folder_name: str, |
| 550 | query: Optional[str] = None, |
| 551 | state_str: Optional[str] = None, |
| 552 | session_id: Optional[str] = None, |
| 553 | replay: Optional[str] = None, |
| 554 | timeout: Optional[str] = None, |
| 555 | in_memory: bool = False, |
| 556 | jsonl: bool = False, |
| 557 | session_service_uri: Optional[str] = None, |
| 558 | artifact_service_uri: Optional[str] = None, |
| 559 | memory_service_uri: Optional[str] = None, |
| 560 | use_local_storage: bool = True, |
| 561 | default_llm_model: Optional[str] = None, |
| 562 | ) -> int: |
| 563 | """Runs an agent in query/automated mode.""" |
| 564 | ( |
| 565 | agent_or_app, |
| 566 | session_service, |
| 567 | artifact_service, |
| 568 | memory_service, |
| 569 | credential_service, |
| 570 | user_id, |
| 571 | session_app_name, |
| 572 | agent_root, |
| 573 | ) = _setup_runner_context( |
| 574 | agent_parent_dir=agent_parent_dir, |
| 575 | agent_folder_name=agent_folder_name, |
| 576 | in_memory=in_memory, |
| 577 | session_service_uri=session_service_uri, |
| 578 | artifact_service_uri=artifact_service_uri, |
| 579 | memory_service_uri=memory_service_uri, |
| 580 | use_local_storage=use_local_storage, |
| 581 | default_llm_model=default_llm_model, |
| 582 | ) |
| 583 | |
| 584 | parsed_state = None |
| 585 | if state_str: |
| 586 | try: |
| 587 | parsed_state = json.loads(state_str) |
| 588 | except json.JSONDecodeError as e: |
| 589 | click.secho(f'Error: Invalid JSON for --state: {e}', fg='red', err=True) |
| 590 | return 1 |
| 591 | |
| 592 | if query and replay: |
| 593 | click.secho( |
| 594 | 'Error: Cannot provide both query and --replay.', fg='red', err=True |
| 595 | ) |
| 596 | return 1 |
| 597 | |
| 598 | if not query and not replay: |
| 599 | if not sys.stdin.isatty(): |
| 600 | query = sys.stdin.read().strip() |
| 601 | else: |
| 602 | click.secho( |
| 603 | 'Error: Missing query argument or stdin input.', fg='red', err=True |
no test coverage detected