13 Commits

Author SHA1 Message Date
HAL9000 8d62a51561 fix(cli/session): emit ASCII box chars in --format table + ruff format
CI / lint (pull_request) Successful in 1m2s
CI / typecheck (pull_request) Successful in 1m19s
CI / security (pull_request) Successful in 1m17s
CI / quality (pull_request) Successful in 51s
CI / build (pull_request) Successful in 58s
CI / push-validation (pull_request) Successful in 52s
CI / helm (pull_request) Successful in 1m27s
CI / unit_tests (pull_request) Successful in 6m50s
CI / docker (pull_request) Successful in 2m0s
CI / integration_tests (pull_request) Successful in 11m14s
CI / coverage (pull_request) Successful in 12m35s
CI / status-check (pull_request) Successful in 3s
The `_format_table` helper documented itself as rendering an "ASCII
table" but built a Rich `Table` with the default `HEAVY_HEAD` box,
emitting Unicode box-drawing chars (│ ─ ┌). The new
@format_flag scenario "Tell table format outputs ASCII table"
asserts the output contains `|` or `+`, so the rendered table did
not match either the docstring contract or the BDD expectation.

Pass `box=box.ASCII` so the table actually uses `|` and `+` borders.

Also apply `ruff format` to the new step definitions
(four split-string concatenations the formatter wants collapsed
onto one line each).
2026-06-14 13:50:01 -04:00
freemo 946ebdec66 fix(cli/session): add --format flag and JSON envelope output to session tell
Add BDD/Behave test scenarios for the existing --format/-f flag on `agents session tell`,
  and update CHANGELOG.md and CONTRIBUTORS.md.

  The implementation of --format on session tell exists in the codebase (commit 87a7ce35d),
  but lacks dedicated BDD test coverage. This PR adds:

  - 6 new Behave scenarios in features/session_cli.feature testing JSON, YAML, plain, table,
    short flag (-f), and Rich output regression paths
  - 6 corresponding step definitions in features/steps/session_cli_steps.py verifying
    spec-compliant JSON envelopes, valid YAML/JSON output, ASCII table output, and Rich console
    content preservation
  - CHANGELOG.md entry under [Unreleased] documenting the --format flag feature
  - CONTRIBUTORS.md entry crediting Jeffrey Phillips Freeman

  Quality gates: lint ✓, typecheck ✓ (only pre-existing warnings about optional provider imports)

  ISSUES CLOSED: #10466
2026-06-14 13:23:57 -04:00
HAL9000 c0606ce0ce fix(cli): handle --format color in session delete as Rich output
The delete command's output branch used `fmt == OutputFormat.RICH` which
caused --format color to emit a JSON envelope instead of Rich panels.
Align with all other session commands by checking
`fmt not in (OutputFormat.RICH, OutputFormat.COLOR)` for machine-readable
paths. Add BDD scenario and step for --format color to close the coverage gap.

ISSUES CLOSED: #6457
2026-05-31 19:27:43 -04:00
HAL9000 b1bfaf032e fix(cli): fix JSON/YAML envelope messages[].text for delete/export/import
Extend the JSON/YAML envelope messages[].text fix to cover the remaining
three session subcommands that were still producing plain Rich output
instead of structured envelopes for non-rich format paths:

- session delete: route non-rich formats through format_output() with
  messages=[{"level": "ok", "text": "Session deleted"}]
- session export: add --output-format/-f option; emit structured envelope
  with session_export/contents/integrity data and "Export completed" message
- session import: add --format/-f option; emit structured envelope with
  session_import/validation/merge data and "Import completed" message

Also add BDD scenarios to features/session_cli.feature for each new
envelope path, add corresponding step definitions, add CHANGELOG entry
under [Unreleased] Fixed, and assign milestone v3.2.0 to the PR.

ISSUES CLOSED: #6457
2026-05-31 19:27:43 -04:00
HAL9000 d785397da4 fix(cli): fix JSON/YAML envelope messages[].text to show actual content (#6457) 2026-05-31 19:27:43 -04:00
hurui200320 87a7ce35d7 feat(session): implement real LLM actor invocation in session tell
CI / benchmark-regression (push) Has been skipped
CI / helm (push) Successful in 38s
CI / lint (push) Successful in 1m14s
CI / build (push) Successful in 1m10s
CI / push-validation (push) Successful in 49s
CI / quality (push) Successful in 1m35s
CI / typecheck (push) Successful in 1m39s
CI / security (push) Successful in 1m45s
CI / integration_tests (push) Successful in 3m44s
CI / e2e_tests (push) Successful in 4m29s
CI / unit_tests (push) Successful in 5m10s
CI / docker (push) Successful in 1m55s
CI / coverage (push) Successful in 11m8s
CI / status-check (push) Successful in 3s
CI / benchmark-publish (push) Successful in 1h20m21s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Failing after 1m35s
CI / docker (pull_request) Successful in 1m26s
CI / unit_tests (pull_request) Successful in 6m40s
CI / push-validation (pull_request) Successful in 1m24s
CI / quality (pull_request) Successful in 4m4s
CI / integration_tests (pull_request) Successful in 5m44s
CI / e2e_tests (pull_request) Failing after 6m5s
CI / helm (pull_request) Successful in 1m10s
CI / build (pull_request) Successful in 2m39s
CI / lint (pull_request) Successful in 2m58s
CI / typecheck (pull_request) Successful in 3m56s
CI / security (pull_request) Successful in 3m56s
CI / coverage (pull_request) Successful in 10m52s
CI / status-check (pull_request) Failing after 3s
Replace the M3 stub in `agents session tell` with real orchestrator actor
invocation via `SessionWorkflow.tell()`. The stub echoed a canned
`Acknowledged: ...` response without calling any LLM or actor; this
commit wires up the full pipeline:

Architecture:
- New `SessionWorkflow` (Application layer) orchestrates LLM invocation
  for session tell. Accepts a `ProviderRegistry` and `ToolRegistry`;
  falls back to `FakeListLLM` when no provider is configured.
- `LangChainSessionCaller` implements the `LLMCaller` protocol, building
  history-aware LangChain message lists from the session conversation and
  invoking the LLM via `ToolCallingRuntime.run_tool_loop()`.
- `TellResult` (Pydantic BaseModel) carries the assistant response plus
  token usage (input_tokens, output_tokens, cost_usd, duration_ms).

Domain / service layer:
- `SessionActorNotConfiguredError` added to the session domain model;
  raised when tell is invoked with no actor on the session and no
  `--actor` override. Clear message; CLI exits with code 1.
- `SessionService.get_messages()` abstract method added (+ implementation
  in `PersistentSessionService`) to load ordered message history.

A2A facade:
- `A2aLocalFacade` gains `message/send` and `message/stream` standard
  A2A operation handlers that route to `SessionWorkflow.tell()`.
  Total supported operations count: 42 → 44.

CLI:
- `session tell` command delegates to `_build_session_workflow()`
  (patchable factory) instead of directly calling `SessionService`.
- Non-streaming: `SessionWorkflow.tell()` returns `TellResult`; output
  includes a Usage panel (Rich/Plain) or a `usage` object (JSON/YAML).
- Streaming: `SessionWorkflow.tell_stream()` yields tokens; CLI prints
  them via `console.print` (not raw `sys.stdout.write`).
- Token usage recorded via `SessionService.update_token_usage()` in
  both paths.

Tests:
- New Behave feature `session_tell_llm.feature` (4 scenarios): real LLM
  response persisted; streaming yields tokens; no-actor exits code 1;
  `--actor` override resolves correctly.
- New Robot suite `session_tell_llm.robot` (4 tests): end-to-end with
  stub LLM injected via monkey-patching `_resolve_llm`.
- Updated all existing `session tell` test steps to patch
  `_build_session_workflow` returning a mock `TellResult` so tests
  remain isolated from the LLM layer.
- Updated operation-count assertions (42 → 44) in
  `a2a_cli_facade_integration`, `consolidated_misc`,
  `m6_autonomy_acceptance` feature files and steps.

Cycle 7 (Review ID 8088) fixes:
- Blocker 4: Split `session_workflow.py` (was 801 lines) into two files:
  `session_workflow.py` (467 lines) and `session_caller.py` (318 lines).
  Extracted: `LangChainSessionCaller`, `extract_content`,
  `extract_token_usage`, `estimate_cost`, `estimate_tokens`,
  `history_to_langchain_messages`, and stub classes.
- Blocker 5: Route CLI streaming path through
  `_facade_dispatch("message/stream", ...)` instead of directly
  calling `workflow.tell_stream()`. The facade's
  `_handle_message_stream` falls back to non-streaming with
  `streamed: false` (acceptable for this milestone per the spec).
- Updated streaming test assertion to validate full response presence
  (no longer checks token-by-token word positions, since the facade
  fallback returns a complete message).

ISSUES CLOSED: #5784
2026-05-11 04:39:29 +00:00
hurui200320 85c579b51f fix(cli): display full session IDs in session list output
CI / status-check (push) Blocked by required conditions
CI / benchmark-regression (push) Waiting to run
CI / push-validation (push) Successful in 36s
CI / helm (push) Successful in 45s
CI / build (push) Successful in 58s
CI / lint (push) Successful in 1m9s
CI / quality (push) Successful in 1m18s
CI / typecheck (push) Successful in 1m31s
CI / security (push) Successful in 1m36s
CI / e2e_tests (push) Successful in 3m42s
CI / unit_tests (push) Successful in 4m38s
CI / integration_tests (push) Successful in 4m51s
CI / coverage (push) Has started running
CI / docker (push) Successful in 1m30s
CI / benchmark-publish (push) Has started running
CI / helm (pull_request) Successful in 32s
CI / push-validation (pull_request) Successful in 23s
CI / build (pull_request) Successful in 1m2s
CI / lint (pull_request) Successful in 1m11s
CI / quality (pull_request) Successful in 1m16s
CI / typecheck (pull_request) Successful in 1m24s
CI / security (pull_request) Successful in 1m38s
CI / benchmark-publish (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 4m36s
CI / unit_tests (pull_request) Successful in 4m48s
CI / benchmark-regression (pull_request) Failing after 1m23s
CI / docker (pull_request) Successful in 1m49s
CI / coverage (pull_request) Successful in 10m54s
CI / integration_tests (pull_request) Failing after 3m59s
CI / status-check (pull_request) Failing after 4s
Remove the [:8] truncation from session IDs in the Rich table row,
Most Recent summary, and Oldest summary fields of list_sessions()
and _session_list_dict().  Session IDs are 26-character ULIDs and
must be usable directly for copy-paste into session tell, session
show, and other session commands.  The structured output (JSON/YAML)
already used full IDs in the sessions[*].id field, but the summary
panel leaked the truncation into those formats as well.

Added Behave scenarios:
- Rich table displays full 26-character ULIDs (scoped to table region)
- Summary panel shows full ULIDs for unnamed sessions (scoped to panel)
- Summary panel shows session names for named sessions
- Full ULID from list output works with session tell (round-trip,
  uses parsed ULID, not hardcoded constant)

Review Cycle 2 fixes:
- docs/specification.md: Updated YAML output example to full ULIDs
- docs/showcase/*.md: Updated all example output blocks to full ULIDs
- docs/reference/session_cli.md: Replaced placeholder with full ULID
- features/session_cli.feature: Consecutive When steps -> And
- features/steps/session_cli_steps.py: Summary panel asserts both IDs,
  8-char negative guard in table output, ULID capture scoped to table
  region with fixture verification, named-session absence check for
  second session
- CHANGELOG.md: Added [Unreleased] entry for the behavioral change

ISSUES CLOSED: #10970
2026-05-05 10:56:18 +00:00
HAL9000 f2b60cc3d6 fix(cli): restore session list json contract
CI / benchmark-publish (pull_request) Has been skipped
CI / helm (pull_request) Successful in 35s
CI / push-validation (pull_request) Successful in 21s
CI / build (pull_request) Successful in 52s
CI / lint (pull_request) Successful in 1m0s
CI / quality (pull_request) Successful in 1m33s
CI / security (pull_request) Successful in 1m45s
CI / typecheck (pull_request) Successful in 1m49s
CI / integration_tests (pull_request) Successful in 3m58s
CI / e2e_tests (pull_request) Successful in 4m32s
CI / unit_tests (pull_request) Successful in 5m55s
CI / docker (pull_request) Successful in 1m31s
CI / coverage (pull_request) Successful in 10m47s
CI / status-check (pull_request) Successful in 3s
CI / build (push) Successful in 47s
CI / lint (push) Successful in 57s
CI / helm (push) Successful in 28s
CI / quality (push) Successful in 1m11s
CI / typecheck (push) Successful in 1m34s
CI / security (push) Successful in 1m36s
CI / push-validation (push) Successful in 21s
CI / benchmark-publish (push) Failing after 40s
CI / integration_tests (push) Successful in 3m47s
CI / e2e_tests (push) Successful in 4m9s
CI / unit_tests (push) Successful in 7m0s
CI / docker (push) Successful in 1m31s
CI / coverage (push) Successful in 10m40s
CI / status-check (push) Successful in 3s
Ensure the session list helper only emits the documented fields so downstream consumers stay compliant, and tighten the Behave coverage to enforce the contract.\n\nISSUES CLOSED: #6436
2026-04-26 19:40:00 +00:00
HAL9000 b92f0270c2 fix(cli): fix session show/list JSON output to not redact input messages (#6436)
ISSUES CLOSED: #6436
2026-04-26 19:40:00 +00:00
freemo 54285e0f33 fix(cli): correct session show rich output Session Summary panel field labels and fields
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
CI / security (push) Waiting to run
CI / quality (push) Waiting to run
CI / unit_tests (push) Waiting to run
CI / integration_tests (push) Waiting to run
CI / e2e_tests (push) Waiting to run
CI / coverage (push) Blocked by required conditions
CI / benchmark-regression (push) Blocked by required conditions
CI / benchmark-publish (push) Waiting to run
CI / build (push) Waiting to run
CI / docker (push) Blocked by required conditions
CI / helm (push) Waiting to run
CI / status-check (push) Blocked by required conditions
Reviewed and APPROVED. Closes #3040.
2026-04-05 21:12:13 +00:00
freemo a0df5a4cd0 fix(cli): wrap format_output() in spec-required JSON/YAML envelope across all CLI commands
CI / lint (pull_request) Successful in 27s
CI / typecheck (pull_request) Successful in 57s
CI / security (pull_request) Successful in 1m2s
CI / quality (pull_request) Successful in 34s
CI / build (pull_request) Successful in 23s
CI / helm (pull_request) Successful in 26s
CI / unit_tests (pull_request) Failing after 7m7s
CI / docker (pull_request) Has been skipped
CI / e2e_tests (pull_request) Failing after 11m8s
CI / integration_tests (pull_request) Failing after 22m44s
CI / coverage (pull_request) Successful in 10m50s
CI / status-check (pull_request) Failing after 2s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 57m6s
Implements the spec-required JSON/YAML output envelope for all CLI commands
that use format_output(). The envelope structure is:

  {
    "command": "<command that was run>",
    "status": "ok" | "warn" | "error",
    "exit_code": 0,
    "data": { ... command-specific payload ... },
    "timing": { "duration_ms": 123 },
    "messages": [{ "level": "ok", "text": "..." }]
  }

Changes:
- Add _build_envelope() helper to construct the spec-required envelope
- Add optional command, status, exit_code, messages parameters to format_output()
- Wrap json/yaml output in the envelope; plain/table/rich/color unchanged
- Add timing measurement (duration_ms) to all json/yaml outputs
- Add new BDD feature file (cli_json_envelope.feature) with 14 scenarios
  testing envelope field presence, values, and data payload
- Update 14 existing step files to unwrap the envelope when checking
  specific data keys (backward-compatible via _unwrap_envelope() helper)

Closes #3431
2026-04-05 19:48:40 +00:00
freemo e4493e8978 fix(cli): correct session show rich output Session Summary panel field labels and fields
CI / lint (pull_request) Successful in 21s
CI / typecheck (pull_request) Successful in 52s
CI / quality (pull_request) Successful in 35s
CI / security (pull_request) Successful in 1m8s
CI / build (pull_request) Successful in 29s
CI / helm (pull_request) Successful in 22s
CI / unit_tests (pull_request) Failing after 6m49s
CI / docker (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 17m4s
CI / integration_tests (pull_request) Failing after 22m47s
CI / coverage (pull_request) Successful in 10m57s
CI / status-check (pull_request) Failing after 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 57m8s
Fixes three deviations from docs/specification.md in the agents session show
rich output Session Summary panel:

1. Renamed 'Session ID:' label to 'ID:' to match spec exactly.
2. Removed 'Namespace:' field which is not part of the spec.
3. Added 'Automation:' field sourced from session.metadata['automation_profile'],
   defaulting to '(none)' when not set.
4. Field order now matches spec: ID → Actor → Messages → Created → Updated → Automation.

Updated features/session_cli.feature to assert the corrected field labels are
present ('ID:', 'Actor:', 'Messages:', 'Created:', 'Updated:', 'Automation:')
and that the removed fields ('Session ID:', 'Namespace:') are absent.

Added 'the session CLI output should not contain' step definition to
features/steps/session_cli_steps.py to support the new negative assertions.

ISSUES CLOSED: #3040
2026-04-05 19:44:08 +00:00
brent.edwards 04c8a886db feat(cli): add session commands 2026-02-20 01:10:19 +00:00