MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / advisor_command_call

Function advisor_command_call

src/command_system/builtins.py:681–990  ·  view source on GitHub ↗

Handle /advisor — configure the reviewer model. Required argument shape: `` : `` — both halves explicit, separated by the first colon (so model strings containing ``/`` or further ``:`` are preserved verbatim). Provider must match a key in ``~/.clawcodex/config.json``

(args: str, context: CommandContext)

Source from the content-addressed store, hash-verified

679
680
681def advisor_command_call(args: str, context: CommandContext) -> LocalCommandResult:
682 """Handle /advisor — configure the reviewer model.
683
684 Required argument shape: ``<provider>:<model>`` — both halves
685 explicit, separated by the first colon (so model strings
686 containing ``/`` or further ``:`` are preserved verbatim).
687 Provider must match a key in ``~/.clawcodex/config.json``&#x27;s
688 ``providers`` map; clawcodex is multi-provider and the same
689 model name (e.g. ``claude-opus-4-7``) can sit behind anthropic,
690 openai (litellm), openrouter, bedrock, etc. Name-based inference
691 was ambiguous and silently routed to the wrong endpoint.
692
693 Branches (after parsing optional ``--client`` / ``--no-client``):
694 * no args, no flags → status report (provider/model + mode).
695 * ``unset`` | ``off`` → clear advisor_model, advisor_provider,
696 and advisor_client_mode.
697 * ``--no-client`` alone → keep model+provider, clear client-mode.
698 * ``--client`` alone → keep model+provider, set client-mode.
699 * ``<provider>:<model>`` → validate provider exists in config,
700 persist both fields together. ``--client`` flag (if present)
701 also persists advisor_client_mode.
702
703 Examples:
704 * ``/advisor anthropic:claude-opus-4-7`` (direct Anthropic API)
705 * ``/advisor openai:claude-opus-4-7`` (litellm/proxy via openai provider)
706 * ``/advisor openrouter:anthropic/claude-opus-4.1``
707 * ``/advisor gemini:gemini-2.5-pro``
708 """
709 from ..models.model import canonical_model_name, resolve_model
710 from ..models.validation import validate_model_name
711 from ..utils.advisor import (
712 ADVISOR_MODE_CLIENT_SIDE,
713 ADVISOR_MODE_INACTIVE,
714 ADVISOR_MODE_SERVER_SIDE,
715 can_user_configure_advisor,
716 decide_advisor_mode,
717 )
718
719 provider = getattr(context, "provider", None)
720
721 # Hard-reject only when env-disabled (the user would silently
722 # configure a value that no request can use).
723 if not can_user_configure_advisor(provider):
724 return LocalCommandResult(
725 type="text",
726 value=(
727 "Advisor is disabled by the CLAUDE_CODE_DISABLE_ADVISOR_TOOL "
728 "env var."
729 ),
730 )
731
732 # Tokenize raw args so flag handling is order-insensitive. A
733 # trailing or leading ``--client`` / ``--no-client`` should peel
734 # off cleanly without breaking the model identifier.
735 raw_tokens = (args or "").strip().split()
736 force_client_flag: bool | None = None # None = no flag passed
737 rest_tokens: list[str] = []
738 for tok in raw_tokens:

Calls 15

LocalCommandResultClass · 0.85
_render_statusFunction · 0.85
_write_advisor_modelFunction · 0.85
_write_advisor_providerFunction · 0.85
_write_advisor_enabledFunction · 0.85