(
self,
prompt: str,
matched_commands: tuple[str, ...] = (),
matched_tools: tuple[str, ...] = (),
denied_tools: tuple[PermissionDenial, ...] = (),
)
| 104 | ) |
| 105 | |
| 106 | def stream_submit_message( |
| 107 | self, |
| 108 | prompt: str, |
| 109 | matched_commands: tuple[str, ...] = (), |
| 110 | matched_tools: tuple[str, ...] = (), |
| 111 | denied_tools: tuple[PermissionDenial, ...] = (), |
| 112 | ): |
| 113 | yield {'type': 'message_start', 'session_id': self.session_id, 'prompt': prompt} |
| 114 | if matched_commands: |
| 115 | yield {'type': 'command_match', 'commands': matched_commands} |
| 116 | if matched_tools: |
| 117 | yield {'type': 'tool_match', 'tools': matched_tools} |
| 118 | if denied_tools: |
| 119 | yield {'type': 'permission_denial', 'denials': [denial.tool_name for denial in denied_tools]} |
| 120 | result = self.submit_message(prompt, matched_commands, matched_tools, denied_tools) |
| 121 | yield {'type': 'message_delta', 'text': result.output} |
| 122 | yield { |
| 123 | 'type': 'message_stop', |
| 124 | 'usage': {'input_tokens': result.usage.input_tokens, 'output_tokens': result.usage.output_tokens}, |
| 125 | 'stop_reason': result.stop_reason, |
| 126 | 'transcript_size': len(self.transcript_store.entries), |
| 127 | } |
| 128 | |
| 129 | def compact_messages_if_needed(self) -> None: |
| 130 | if len(self.mutable_messages) > self.config.compact_after_turns: |
no test coverage detected