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

Function clear_command_call

src/command_system/builtins.py:148–182  ·  view source on GitHub ↗

Handle /clear command - clear conversation history. Args: args: Command arguments context: Command context Returns: LocalCommandResult

(args: str, context: CommandContext)

Source from the content-addressed store, hash-verified

146
147
148def clear_command_call(args: str, context: CommandContext) -> LocalCommandResult:
149 """
150 Handle /clear command - clear conversation history.
151
152 Args:
153 args: Command arguments
154 context: Command context
155
156 Returns:
157 LocalCommandResult
158 """
159 if hasattr(context.conversation, "clear"):
160 context.conversation.clear()
161
162 if hasattr(context.history, "events"):
163 context.history.events.clear()
164
165 # ch05 round-3 G3: a cleared conversation restarts the cache epoch —
166 # reset memoized prompt sections + beta-header latches (TS
167 # clearSystemPromptSections via /clear, commands/clear/caches.ts:74).
168 # Direct call, NOT run_post_compact_cleanup: /clear must not register
169 # as a compaction (pending_post_compaction telemetry).
170 try:
171 from src.context_system.system_prompt_cache import (
172 clear_system_prompt_sections,
173 )
174
175 clear_system_prompt_sections()
176 except Exception:
177 pass
178
179 return LocalCommandResult(
180 type="text",
181 value="Conversation cleared.",
182 )
183
184
185def help_command_call(args: str, context: CommandContext) -> LocalCommandResult:

Calls 3

LocalCommandResultClass · 0.85
clearMethod · 0.45