Skip to content

fix: v0.7.3 — agent create kb_ref kwarg leak; log shell exceptions - #19

Merged
dshahnaz merged 1 commit into
mainfrom
fix/v0.7.3-agent-create-kb-ref-leak
Apr 17, 2026
Merged

dshahnaz merged 1 commit into
mainfrom
fix/v0.7.3-agent-create-kb-ref-leak

Conversation

@dshahnaz

Copy link
Copy Markdown
Owner

Summary

  • Fix TypeError: agent_create() got an unexpected keyword argument 'kb_ref' — the KB→index picker cascade added in v0.7.2 stashes the picked KB into PickerContext.answers["kb_ref"], but _dispatch then fed the full answers dict through spec.callback(**answers) — and agent_create declares no kb_ref parameter. The dispatcher now filters answers to declared spec.params names before invoking. Any future picker that stashes side-channel state stays contained.
  • Log shell exceptions to ~/.pais/logs/pais.log — previously the top-level handlers in enter_interactive only printed error: … to the console. pais doctor / pais logs tail couldn't recover the traceback. Both the flat-menu dispatch path and the workflow path now emit shell.command_crashed / shell.workflow_crashed (with full traceback) via the existing structlog logger before printing.

Test plan

  • uv run ruff check && uv run ruff format --check
  • uv run mypy src
  • uv run pytest -q — 384 passed (was 381 pre-fix; +2 regressions, +1 logging test)
  • New: test_dispatch_filters_picker_scratch_keys — picker stashing a bogus key doesn't crash a strict callback.
  • New: test_agent_create_flow_picks_kb_then_index now asserts kb_ref not in captured.
  • New: test_shell_logs_command_exceptions — shell.command_crashed event is emitted when dispatched command raises.
  • Manual E2E against real PAIS: pais → agent create → pick model → pick KB → pick index → Go → agent created, no TypeError.

🤖 Generated with Claude Code

… file

- Filter `answers` to declared `spec.params` before `spec.callback(**answers)`
  so picker scratch state (e.g. `kb_ref` from the KB→index cascade) no longer
  leaks through as an unexpected kwarg. Fixes `TypeError: agent_create() got
  an unexpected keyword argument 'kb_ref'` regressed in v0.7.2.
- Log shell command + workflow exceptions via `pais.logging.get_logger` so
  tracebacks land in `~/.pais/logs/pais.log` and are recoverable via
  `pais doctor` / `pais logs tail`.
- Bump to 0.7.3; CHANGELOG entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dshahnaz
dshahnaz merged commit 4b91f1b into main Apr 17, 2026
3 checks passed
@dshahnaz
dshahnaz deleted the fix/v0.7.3-agent-create-kb-ref-leak branch April 17, 2026 14:20
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.

1 participant