Module: Brute
- Defined in:
- lib/brute/patches/buffer_nil_guard.rb,
lib/brute.rb,
lib/brute/diff.rb,
lib/brute/agent.rb,
lib/brute/skill.rb,
lib/brute/tools.rb,
lib/brute/prompts.rb,
lib/brute/version.rb,
lib/brute/pipeline.rb,
lib/brute/loop/step.rb,
lib/brute/providers.rb,
lib/brute/middleware.rb,
lib/brute/tools/shell.rb,
lib/brute/prompts/base.rb,
lib/brute/store/session.rb,
lib/brute/system_prompt.rb,
lib/brute/tools/fs_read.rb,
lib/brute/tools/fs_undo.rb,
lib/brute/loop/compactor.rb,
lib/brute/loop/doom_loop.rb,
lib/brute/prompts/skills.rb,
lib/brute/tools/delegate.rb,
lib/brute/tools/fs_patch.rb,
lib/brute/tools/fs_write.rb,
lib/brute/tools/question.rb,
lib/brute/loop/agent_turn.rb,
lib/brute/middleware/base.rb,
lib/brute/middleware/otel.rb,
lib/brute/providers/shell.rb,
lib/brute/tools/fs_remove.rb,
lib/brute/tools/fs_search.rb,
lib/brute/tools/net_fetch.rb,
lib/brute/tools/todo_read.rb,
lib/brute/middleware/retry.rb,
lib/brute/prompts/autonomy.rb,
lib/brute/prompts/identity.rb,
lib/brute/providers/ollama.rb,
lib/brute/queue/base_queue.rb,
lib/brute/store/todo_store.rb,
lib/brute/tools/todo_write.rb,
lib/brute/loop/agent_stream.rb,
lib/brute/orchestrator/turn.rb,
lib/brute/prompts/max_steps.rb,
lib/brute/middleware/tracing.rb,
lib/brute/prompts/code_style.rb,
lib/brute/prompts/git_safety.rb,
lib/brute/prompts/tool_usage.rb,
lib/brute/loop/tool_call_step.rb,
lib/brute/middleware/llm_call.rb,
lib/brute/prompts/conventions.rb,
lib/brute/prompts/doing_tasks.rb,
lib/brute/prompts/environment.rb,
lib/brute/prompts/objectivity.rb,
lib/brute/store/message_store.rb,
lib/brute/middleware/otel/span.rb,
lib/brute/prompts/build_switch.rb,
lib/brute/prompts/instructions.rb,
lib/brute/providers/models_dev.rb,
lib/brute/queue/parallel_queue.rb,
lib/brute/store/snapshot_store.rb,
lib/brute/prompts/plan_reminder.rb,
lib/brute/prompts/proactiveness.rb,
lib/brute/prompts/frontend_tasks.rb,
lib/brute/prompts/tone_and_style.rb,
lib/brute/queue/sequential_queue.rb,
lib/brute/prompts/code_references.rb,
lib/brute/prompts/task_management.rb,
lib/brute/prompts/editing_approach.rb,
lib/brute/providers/shell_response.rb,
lib/brute/middleware/token_tracking.rb,
lib/brute/middleware/tool_use_guard.rb,
lib/brute/queue/file_mutation_queue.rb,
lib/brute/middleware/otel/tool_calls.rb,
lib/brute/middleware/compaction_check.rb,
lib/brute/middleware/message_tracking.rb,
lib/brute/middleware/otel/token_usage.rb,
lib/brute/patches/anthropic_tool_role.rb,
lib/brute/prompts/editing_constraints.rb,
lib/brute/prompts/security_and_safety.rb,
lib/brute/middleware/otel/tool_results.rb,
lib/brute/middleware/doom_loop_detection.rb,
lib/brute/middleware/session_persistence.rb,
lib/brute/middleware/tool_error_tracking.rb,
lib/brute/middleware/reasoning_normalizer.rb
Overview
Monkey-patch: Fix Anthropic tool result message role.
llm.rb stores tool results as messages with role=“tool” (via @llm.tool_role). Anthropic’s API requires tool result messages to have role=“user” with tool_result content blocks. The Completion adapter already correctly formats the content (Function::Return -> “tool_result”, …), but passes through the “tool” role unchanged — which Anthropic rejects.
This patch overrides adapt_message to set role=“user” when the message content contains tool returns.
Defined Under Namespace
Modules: Diff, Loop, Middleware, Patches, Prompts, Providers, Queue, Skill, Store, Tools Classes: Agent, Orchestrator, Pipeline, SystemPrompt
Constant Summary collapse
- VERSION =
"1.0.1"
Class Method Summary collapse
Class Method Details
.provider ⇒ Object
23 24 25 |
# File 'lib/brute.rb', line 23 def self.provider @provider ||= Brute::Providers.guess_from_env end |
.provider=(p) ⇒ Object
27 28 29 |
# File 'lib/brute.rb', line 27 def self.provider=(p) @provider = p end |