Add an oracle tool that consults a reasoning model for planning, debugging, or architectural decisions.
When jr encounters complex problems (multi-file refactors, debugging, architectural decisions), it should be able to "step back" and consult a more powerful reasoning model.
data OracleArgs = OracleArgs
{ oracleTask :: Text -- The question/problem to analyze
, oracleContext :: Maybe Text -- Optional context about current situation
, oracleFiles :: Maybe [Text] -- Optional file paths to include in context
}
deriving (Show, Eq, Generic)
oracleTool :: Text -> Engine.Tool -- Takes API key
oracleTool apiKey = Engine.Tool
{ Engine.toolName = "oracle",
Engine.toolDescription = "Consult a reasoning model for complex planning, debugging, or architectural decisions. Use this when you need to think through a difficult problem.",
Engine.toolJsonSchema = ...,
Engine.toolExecute = executeOracle apiKey
}
1. Parse the OracleArgs
2. If oracleFiles is provided, read each file and include in context
3. Build a prompt for the oracle:
`
You are a senior engineering advisor. Analyze the following problem and provide specific, actionable guidance.
## Problem <task>
## Context <context>
## Relevant Files <file contents>
Provide your analysis and recommendations. Be specific about what to do and in what order.
Do not implement - only advise.
`
4. Call OpenRouter API with model "anthropic/claude-sonnet-4" (or make it configurable)
5. Return the oracle response
Use the same OpenRouter API pattern as in Engine.hs:
{
"type": "object",
"properties": {
"task": { "type": "string", "description": "The problem or question to analyze" },
"context": { "type": "string", "description": "Optional context about current situation" },
"files": {
"type": "array",
"items": { "type": "string" },
"description": "Optional file paths to include in the analysis"
}
},
"required": ["task"]
}
Add a simple test that verifies the tool schema is valid. Full integration test would require API key.
CHANGES REQUESTED: Looking at this task implementation, let me evaluate the code changes against the requirements.
Task Requirements Checklist
1. Create the Oracle Tool ✅
oracleToolfunction takes API key and returnsEngine.Tool2. Data Types ✅
OracleArgswithoracleTask,oracleContext,oracleFilesFromJSONinstance3. Implementation ✅
OracleArgscorrectlyoracleFilesis provided (with truncation for large files)4. Tool Schema ✅
5. Testing ✅
allToolsWithOraclebuildOraclePrompt6. Exports ✅
oracleTool,allToolsWithOracle,OracleArgsall exportedBuild/Test Status
Lint Issues
There are lint warnings: 1. File has 1248 lines (max 1000) - this is a pre-existing issue, not introduced by this change 2. Missing shebang - also pre-existing 3. hlint suggestions: Two data types should be
newtypeinstead ofdata:OracleApiResponseOracleChoiceThese hlint suggestions are valid and easy fixes. The code uses
datafor single-field types that should benewtypefor efficiency.Code Quality
Issues Found
1. Lint failure: hlint found 2 issues that should be fixed (
data→newtypefor single-field types)The implementation is correct and complete, but the hlint warnings should be addressed since they represent a lint failure.