Repository navigation
Fix core profile prompt contract - #411
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@coderabbitai review |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR detects the MCP tool profile from ChangesTool-Profile-Aware Native-Agent Prompt and Contract
Sequence DiagramsequenceDiagram
participant Install as inspectClaudeNativeAgentInstall
participant ReadProfile as readInstalledToolProfile
participant BuildPrompt as buildNativeAgentPrompt
participant AssessContract as assessNativeAgentPromptContract
participant Execute as executeNativeAgentCompare
Execute->>Install: check install state
Install->>ReadProfile: derive tool profile from .mcp.json
ReadProfile-->>Install: return 'core' or 'full'
Install-->>Execute: return NativeAgentInstallCheck with tool_profile
Execute->>BuildPrompt: pass question + detected profile
BuildPrompt-->>Execute: return profile-aware prompt text
Note over BuildPrompt: core → retrieve-first<br/>full → context_pack-first
Execute->>AssessContract: evaluate trace with profile
AssessContract->>AssessContract: validate first Madar call<br/>matches profile entry tool
AssessContract-->>Execute: return contract state (followed/violated)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/infrastructure/compare.ts (1)
3572-3584:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPreserve definite contract violations before falling back to
not_measured.If Lines 3572-3579 already establish a deterministic violation, Lines 3580-3584 currently overwrite it with
not_measuredas soon as there is later broad exploration. On a full-profile trace likeretrieve -> Glob, that hides the clear "first Madar call was not context_pack" failure this PR is meant to surface. Worth adding a regression test for that shape too.Suggested fix
if (report.madar_trace.broad_exploration_tool_call_count > 0) { + if (evidence.length > 0) { + evidence.push('broad exploration occurred after the first Madar call, but the trace does not show whether missing_context justified it') + return { + status: 'violated', + evidence, + } + } return { status: 'not_measured', evidence: ['broad exploration occurred after the first Madar call, but the trace does not show whether missing_context justified it'], } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/infrastructure/compare.ts` around lines 3572 - 3584, The code currently pushes a deterministic contract violation via nativeAgentPromptContractViolationEvidence (using nativeAgentPromptContractEntryToolNames and canonicalTraceToolName) but then unconditionally returns a 'not_measured' result when report.madar_trace.broad_exploration_tool_call_count > 0, which overwrites the earlier violation; change the branching so that before returning the 'not_measured' object you check whether evidence already contains the deterministic violation (the object produced by nativeAgentPromptContractViolationEvidence) or whether a non-null violation was previously recorded and, if so, return that violation/status instead of 'not_measured'—i.e., only fall back to the not_measured return when no prior deterministic violation was appended to evidence.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/infrastructure/compare.ts`:
- Around line 3572-3584: The code currently pushes a deterministic contract
violation via nativeAgentPromptContractViolationEvidence (using
nativeAgentPromptContractEntryToolNames and canonicalTraceToolName) but then
unconditionally returns a 'not_measured' result when
report.madar_trace.broad_exploration_tool_call_count > 0, which overwrites the
earlier violation; change the branching so that before returning the
'not_measured' object you check whether evidence already contains the
deterministic violation (the object produced by
nativeAgentPromptContractViolationEvidence) or whether a non-null violation was
previously recorded and, if so, return that violation/status instead of
'not_measured'—i.e., only fall back to the not_measured return when no prior
deterministic violation was appended to evidence.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6585b12f-ca15-4a30-b7c8-a47b9cfeb204
📒 Files selected for processing (3)
src/infrastructure/compare.tstests/unit/compare-native-agent.test.tstests/unit/compare.test.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Fixed the deterministic full-profile violation case that CodeRabbit flagged.
@coderabbitai review |
|
✅ Actions performedReview triggered.
|
Summary
.mcp.jsonso prompt-contract checks validate against the tool actually exposedCloses #405
Verification
Summary by CodeRabbit