Skip to content

[Spec 0022] Stateless consult tool for multi-agent consultation - #30

Merged
waleedkadous merged 2 commits into
mainfrom
builder/0022-consult-tool-stateless
Dec 4, 2025
Merged

waleedkadous merged 2 commits into
mainfrom
builder/0022-consult-tool-stateless

Conversation

@waleedkadous

@waleedkadous waleedkadous commented Dec 4, 2025 •

Copy link
Copy Markdown
Contributor

Summary

  • Add consult CLI tool for invoking external AI models (gemini-cli, codex) with a consultant role
  • Create consultant role definition that positions the consultant as a collaborative partner
  • Support model aliases (gemini/pro, codex/gpt), stdin piping, and query history logging

Changes

  • codev/bin/consult: Python CLI using Typer with autonomous mode (--yolo for gemini, --full-auto for codex)
  • codev/roles/consultant.md: Collaborative consultant role definition
  • codev-skeleton/roles/consultant.md: Copy for new projects
  • codev/requirements.txt: Add typer dependency
  • .gitignore: Add .consult/ for history logs
  • CLAUDE.md / AGENTS.md: Documentation for the consult tool

Usage

./codev/bin/consult gemini "Review this design"
./codev/bin/consult codex "What do you think?"
./codev/bin/consult pro "Review this"  # alias for gemini
echo "Review this" | ./codev/bin/consult gpt
./codev/bin/consult gemini "test" --dry-run

Test plan

  • Verify --help output
  • Test dry-run for all model aliases (gemini, codex, pro, gpt)
  • Test unknown model error handling
  • Test stdin piping
  • Verify history logging to .consult/history.log
  • Live test with gemini-cli (invocation correct, auth is environment-specific)

Revision History

v2 - PR Review Fixes

  • Fixed Typer double-command bug: use typer.run(consult) instead of app pattern
  • Fixed codex env var: CODEX_SYSTEM_MESSAGE (not CODEX_SYSTEM_PROMPT)
  • Moved path constants inside function for lazy loading
  • Use .rstrip() instead of .strip() for stdin to preserve leading whitespace

v1 - Initial Implementation

  • Fixed spec assumption: gemini-cli uses GEMINI_SYSTEM_MD env var (not --system-instructions flag)
  • This is Phase 1 (stateless). Phase 2 (Spec 0023) will add stateful sessions.

…tion

- Add codev/bin/consult Python CLI wrapper for gemini-cli and codex
- Create consultant role definition in codev/roles/consultant.md
- Support model aliases: gemini/pro, codex/gpt
- Use GEMINI_SYSTEM_MD env var for gemini-cli system prompt
- Use CODEX_SYSTEM_PROMPT env var for codex system prompt
- Enable autonomous mode with --yolo (gemini) and --full-auto (codex)
- Log queries to .consult/history.log
- Add --dry-run flag for debugging
- Support stdin piping for queries
- Add typer dependency to codev/requirements.txt
- Update CLAUDE.md and AGENTS.md with documentation
@waleedkadous

Copy link
Copy Markdown
Contributor Author

Architect Review with Expert Consultation

I've reviewed this PR with feedback from Gemini Pro and GPT-5 Codex. The implementation is solid overall, but there are a few issues to address before merge.

🔴 Critical Issues

1. Typer double-command bug (Lines 82, 191-192)

Current Typer setup requires consult consult "query" instead of consult "query".

Fix: Replace @app.command() pattern with typer.run():

# Remove @app.command() decorator
# Change main block to:
if __name__ == "__main__":
    typer.run(consult)

2. Wrong codex env var (Line 148)

The codex CLI expects CODEX_SYSTEM_MESSAGE, not CODEX_SYSTEM_PROMPT.

Fix:

env = {"CODEX_SYSTEM_MESSAGE": role}

🟡 Medium Issues

3. Import-time constants (Lines 45-47)

CODEV_ROOT and ROLE_FILE are computed at import time, which could cause errors before --help works.

Fix: Move these inside get_role() or the consult() function for lazy evaluation.

4. stdin stripping (Line 105)

.strip() removes leading indentation which matters for code snippets.

Fix:

query = sys.stdin.read().rstrip("\n")

✅ What's Good

  • Temp file approach for gemini is correct
  • Consultant role definition is well-scoped
  • Cleanup in finally block handles failures properly
  • KeyboardInterrupt handling is appropriate
  • History logging is non-blocking

Please address these issues and push an update.

- Fix Typer double-command bug: use typer.run(consult) instead of app pattern
- Fix codex env var: CODEX_SYSTEM_MESSAGE (not CODEX_SYSTEM_PROMPT)
- Move path constants inside function for lazy loading
- Use .rstrip() instead of .strip() for stdin to preserve leading whitespace
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