slash-command-bridge
Lets the model invoke a curated set of slash commands via the
run_slash_command tool. Instead of the user manually running
/show-system-prompt or /compact, the model can call these
commands itself when it determines they’re needed.
Available commands
Section titled “Available commands”| Command | Description |
|---|---|
show-system-prompt | Returns the full system prompt text |
context | Returns context window token usage breakdown (or no-data when usage is unknown) |
compact | Triggers session compaction to free context space |
The model calls the tool automatically when appropriate:
run_slash_command({ command: "context" })→ "Context Usage: 45,000 / 200,000 tokens (22.5%)"
run_slash_command({ command: "compact" })→ "Session compaction will begin after this response completes."If usage is unknown (tokens: null), context returns the same no-data error
path as /context for parity.
Model-invoked compact is deferred until the assistant finishes its current
post-tool response. Once compaction actually completes, the bridge schedules a
hidden continuation turn only if the session is still idle, which avoids the
old dead-end where /compact returned successfully but no compaction or resume
happened.
Design
Section titled “Design”This is Phase 1 of the slash command invocation feature. The approach
is pragmatic: commands whose logic is available via ExtensionContext are
executed directly (system prompt access, context usage, compaction).
Commands requiring ExtensionCommandContext (session management like
/clear, /new, /fork) cannot be invoked by the model yet — the
framework doesn’t expose command handler access to tools. Phase 2 will
add an allowModelInvocation flag to command registration and a
framework-level bridge.
Context injection
Section titled “Context injection”The extension injects a hidden message before each agent turn listing the commands the model can invoke via the tool. This ensures the model knows the capability exists without polluting visible conversation.
Extension metadata
Section titled “Extension metadata”| Field | Value |
|---|---|
| Category | tool |
| Enhances | clear, context-usage, show-system-prompt |