Skip to content

refactor(repl): remove /list command and adopt per-domain list subcommands#2713

Merged
Devesh36 merged 9 commits into
Tracer-Cloud:mainfrom
Devesh36:list
Jun 14, 2026
Merged

refactor(repl): remove /list command and adopt per-domain list subcommands#2713
Devesh36 merged 9 commits into
Tracer-Cloud:mainfrom
Devesh36:list

Conversation

@Devesh36

@Devesh36 Devesh36 commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

This pull request refactors how tool listing is handled in the interactive shell and simplifies the slash command catalog. The /list slash command and related logic have been removed, and a new /tools slash command has been introduced to provide direct access to listing registered tools. The help, catalog, and command registry have been updated accordingly, and several code cleanups and improvements have been made.

Slash Command Refactoring and Tool Listing:

  • Removed the /list slash command and all its related logic, including interactive menus and helpers, from integrations.py. Listing tools, integrations, models, and MCP servers is now handled by their dedicated commands. [1] [2] [3]
  • Introduced a new /tools slash command in tools_cmds.py for listing registered tools, with support for subcommands like list and ls. This command is registered in the main command registry and included in help sections. [1] [2] [3] [4]

Help, Catalog, and UI Updates:

  • Updated help sections and catalog descriptions to remove references to /list and add /tools, including updating usage examples and anti-examples in slash_catalog.py. The help section now groups integrations, models, and tools together. [1] [2] [3] [4] [5]
  • Shortened the compact description length in the slash command catalog and ensured that use cases are omitted in compact mode to keep LLM payloads small. [1] [2] [3]

Code Cleanup and Minor Improvements:

  • Removed unused imports and variables related to the old /list command in integrations.py. [1] [2] [3] [4]
  • Improved formatting and usage hints for other slash commands (e.g., /sessions, /tasks) to provide better help and tab-completion support. [1] [2]
  • Minor UI and documentation tweaks for clarity and consistency in command descriptions and argument examples. [1] [2] [3] [4] [5] [6]

These changes make the command structure clearer, improve the user experience for listing tools, and reduce unnecessary complexity in the codebase.

Screenshot 2026-06-03 at 11 57 30 AM Screenshot 2026-06-03 at 11 58 11 AM

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Greptile code review

This repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md.

Run a review — add a PR comment with:

@greptile review

Give it ~5-10 minutes (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5.

Optional: automate with the greploop skill.

@greptile-apps

greptile-apps Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes the /list omnibus command and replaces it with per-domain subcommands (/integrations list, /mcp list, /model show, /tools list). It also adds a graceful fallback in the LLM action planner so that context-overflow errors trigger the deterministic mapper instead of propagating as unhandled exceptions.

  • /list removal: All /list handler code, interactive menus, and catalog entries are deleted from integrations.py. A new tools_cmds.py wires /tools list using the new make_list_root_handler factory in types.py, which centralises unknown-subcommand error handling and session marking.
  • Prompt-overflow fallback (planner.py): PlannerLLMError on context overflow is now caught; the deterministic action mapper is tried first and falls back to assistant_handoff only when it finds nothing actionable. A dedicated test file (test_llm_action_planner_fallback.py) covers Anthropic/OpenAI overflow messages, informational-question preservation, empty-mapper handoff, and non-overflow re-raise.
  • LLM payload reduction (slash_catalog.py, prompting.py): The slash catalog is no longer appended to the system prompt; slash_invoke_tool_description now emits only command names to keep prompt size small under strict token budgets.

Confidence Score: 5/5

Safe to merge — the refactoring is mechanical and well-tested, and the new overflow fallback path is covered by a dedicated test file.

All /list callsites and cross-references (deterministic mapper, registry rules, contract YAMLs, test fixtures) are consistently updated to the new /<domain> list form. The make_list_root_handler factory handles both the happy path and the unknown-subcommand error case correctly. The overflow fallback adds a meaningful resilience improvement and its test suite covers the main edge cases, including informational-question preservation that was a concern in a prior review round.

No files require special attention beyond the minor PEP 8 blank-line nit in failure_explain.py.

Important Files Changed

Filename Overview
app/cli/interactive_shell/command_registry/tools_cmds.py New /tools slash command backed by make_list_root_handler; correctly delegates unknown-subcommand error handling (including session.mark_latest) to the shared factory.
app/cli/interactive_shell/command_registry/types.py Introduces make_list_root_handler factory; properly imports Callable from collections.abc, handles bare invocation (defaults to "list"), marks session ok=False on unknown subcommands.
app/cli/interactive_shell/command_registry/integrations.py Removes /list command, _cmd_list, _interactive_list_menu, and associated unused imports cleanly; remaining integration/MCP commands unchanged.
app/cli/interactive_shell/routing/handle_message_with_agent/orchestration/llm_action_planner/planner.py Adds _plan_prompt_overflow_fallback to handle context-overflow errors gracefully; uses deterministic mapper first before falling back to assistant_handoff. Correct integration with finalize_planner_result_with_trace.
app/integrations/llm_cli/failure_explain.py Extracts is_context_length_overflow helper and tightens regex to avoid false-positive on timeout messages; missing blank line before _NETWORK_RE (PEP 8 E302).
app/cli/interactive_shell/command_registry/slash_catalog.py Removes /list from MCP catalog, adds /tools; reduces slash_invoke_tool_description to name-only list to shrink LLM payload; intentional and documented tradeoff.
app/cli/interactive_shell/routing/handle_message_with_agent/orchestration/llm_action_planner/normalization.py Corrects the /integrations bare-call normalization: no longer redirects to the removed /list integrations; now injects ["list"] arg correctly.
tests/cli/interactive_shell/orchestration/test_llm_action_planner_fallback.py New test file covering the prompt-overflow fallback path with parametrized provider error messages, informational-question preservation, empty-mapper handoff, and non-overflow re-raise.
tests/cli/interactive_shell/test_commands.py Test class renamed and updated to use new command names; old /list-specific tests removed, new /tools list and /model show tests added.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["User types /tools, /integrations, /mcp, /model"] --> B["dispatch_slash"]
    B --> C{"Command match"}
    C -->|"/tools"| D["make_list_root_handler\n(types.py)"]
    C -->|"/integrations"| E["_cmd_integrations\n(integrations.py)"]
    C -->|"/mcp"| F["_cmd_mcp\n(integrations.py)"]
    D --> G{"sub in aliases?"}
    G -->|"list / ls / tool / tools"| H["_list_tools → render_tools_table"]
    G -->|"unknown"| I["print error\nsession.mark_latest(ok=False)"]

    J["User natural language"] --> K["plan_actions_with_llm_result\n(planner.py)"]
    K --> L["_call_llm"]
    L -->|"PlannerLLMError"| M{"is_context_length_overflow?"}
    M -->|"Yes"| N["_plan_prompt_overflow_fallback"]
    M -->|"No"| O["re-raise"]
    N --> P["map_actions_result\n(deterministic mapper)"]
    P -->|"actions found"| Q["finalize_planner_result_with_trace"]
    P -->|"no actions"| R["_fallback_handoff\n(assistant_handoff)"]
    Q --> S["LlmActionPlanResult\npolicy_trace: fallback_prompt_too_long"]
    R --> S
    L -->|"success"| T["_parse_tool_plan → finalize"]
Loading

Reviews (7): Last reviewed commit: "refactor(planner): streamline context le..." | Re-trigger Greptile

Comment thread app/cli/interactive_shell/command_registry/tools_cmds.py Outdated
@Devesh36

Devesh36 commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile-apps review again

@muddlebee

Copy link
Copy Markdown
Collaborator
image

in /agents imo not required, to add agents list its a single command, list will be necessary which has subcommands?

@muddlebee

Copy link
Copy Markdown
Collaborator
image

here also not required, could you cross check?

@muddlebee

Copy link
Copy Markdown
Collaborator
image

not required

@muddlebee

Copy link
Copy Markdown
Collaborator
image

not required

@Devesh36

Devesh36 commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

@muddlebee Thanks for the review — agreed these list aliases were unnecessary. I’ve removed /agents list, /sessions list, /tasks list, and /watches list, so these commands now use the direct form only (/agents, /sessions, /tasks, /watches). I also updated the related tests accordingly.

@Devesh36 Devesh36 requested a review from muddlebee June 3, 2026 16:19
@Devesh36

Devesh36 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile-apps review again

@Davidson3556

Copy link
Copy Markdown
Contributor

great work @Devesh36

can you look in to this: the "prompt too long" fallback never runs. In planner.py the guard checks for the exact phrase "prompt too long", but providers don't say that: Anthropic returns prompt is too long: … and OpenAI says …maximum context length is…. Neither matches, so the error just re-raises and the fallback is dead. Suggest matching on "too long" or a small regex. There's also no test for this path.

Dead code: make_list_root_handler (types.py) has no callers : /tools even copies the same logic inline. Wire it up or drop it.

Stale comments: still reference /list tools / /list mcp / /list integrations in tool_catalog.py:13 and rendering.py:59-60.

Description mismatch: the PR says /agents list/ls and /sessions list were added, but they aren't in the code — /agents list still errors and _cmd_sessions ignores its args.

@Devesh36

Devesh36 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

great work @Devesh36

can you look in to this: the "prompt too long" fallback never runs. In planner.py the guard checks for the exact phrase "prompt too long", but providers don't say that: Anthropic returns prompt is too long: … and OpenAI says …maximum context length is…. Neither matches, so the error just re-raises and the fallback is dead. Suggest matching on "too long" or a small regex. There's also no test for this path.

Dead code: make_list_root_handler (types.py) has no callers : /tools even copies the same logic inline. Wire it up or drop it.

Stale comments: still reference /list tools / /list mcp / /list integrations in tool_catalog.py:13 and rendering.py:59-60.

Description mismatch: the PR says /agents list/ls and /sessions list were added, but they aren't in the code — /agents list still errors and _cmd_sessions ignores its args.

nice catch , i'll resolve this asap

@Devesh36

Devesh36 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile-apps review again

@Devesh36

Devesh36 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile-apps review again

@Devesh36

Devesh36 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile-apps review again

@Devesh36

Copy link
Copy Markdown
Collaborator Author

@greptile-apps review again

@Davidson3556

Copy link
Copy Markdown
Contributor

looks good to me

@muddlebee muddlebee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Devesh36 Devesh36 merged commit 22e638b into Tracer-Cloud:main Jun 14, 2026
14 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

LGTM → Merged. @Devesh36, your work is in. Every commit counts — thank you for this one.


👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome.

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.

3 participants