Handle /clear command - clear conversation history. Args: args: Command arguments context: Command context Returns: LocalCommandResult
(args: str, context: CommandContext)
| 146 | |
| 147 | |
| 148 | def 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 | |
| 185 | def help_command_call(args: str, context: CommandContext) -> LocalCommandResult: |