Skip to content

Record reasoning effort as a column on llm_executions and review_scores #3430

Closed

Description

@integry

Problem

Reasoning effort (low/medium/high/xhigh/max/...) is not a column in any table. It exists only in llm_logs.metadata.reasoningLevel (per call) and in tasks.initial_job_data.reasoningLevel (only when a level-* label overrode it). As a result nothing can report cost or quality by effort, and "cost per merged PR" exists per implementer model only.

Goal

Persist the effective reasoning level of each agent execution and of the implementation behind each review score, so later reporting (cost per merged PR by model and effort, anomaly baselines, escalation policies) can query it directly. This issue adds and populates the columns only; it does not change any report.

Acceptance criteria

  • A new knex migration adds a nullable reasoning_level column to llm_executions and a nullable implementer_reasoning_level column to review_scores. The migration is reversible and safe on existing SQLite databases; existing rows stay null.
  • recordLLMMetrics accepts the effective reasoning level and persistToDatabase writes it. Every existing caller passes the level actually used for that execution (the value already resolved by the agent and available as AgentExecutionResult.reasoningLevel), including the failure-path callers.
  • The stored value is the effective level after precedence resolution (job label override, then per-model agent config, then the instance setting), not just the label override. auto or unknown is stored as-is or null, never guessed.
  • review_scores.implementer_reasoning_level is set at write time in the same place the implementer agent/model are resolved (resolveImplementationTask), from the implementation task's execution row; null when unknown.
  • Agents that encode effort in the model id or do not support effort store null without error.
  • No existing API response shape, CSV column set or UI changes in this issue.
  • Tests: migration test (up/down, existing rows), recordLLMMetrics persistence with and without a level, and review-score persistence carrying the implementer level.

Out of scope

  • Backfilling historical rows.
  • Adding effort to analytics endpoints, the review-scores CSV, the CLI or the UI (separate follow-up).

Implementation

Key files:

  • Migrations: packages/core/src/db/migrations/ (see 20261006000000_create_review_scores.js and the llm_executions extensions 20260204000000, 20260415000000, 20261008000000 for style).
  • packages/core/src/utils/llmMetrics.ts: recordLLMMetrics, persistToDatabase, PersistMetrics.
  • Callers of recordLLMMetrics: src/jobs/issueJob/agent.ts, src/jobs/processPullRequestCommentJob.ts, src/jobs/reviewResultMetrics.ts, src/jobs/mergeConflictAgentRunner.ts, src/jobs/processGoalJob.ts, and failure paths in src/jobs/errorHandlers.ts and src/jobs/prCommentJobUtils.ts.
  • Effective level resolution: resolveEffectiveReasoningLevel in packages/core/src/agents/impl/ClaudeAgent.ts and CodexAgent.ts; levels in packages/shared/src/reasoningLevels.ts.
  • packages/core/src/services/reviewScoreStore.ts: resolveImplementationTask, recordReviewScores; writer src/jobs/reviewScorePersistence.ts.

Approach: add the migration; extend the metrics input type and insert; thread the level from the agent result at each caller; extend the review-score store to read the implementation task's llm_executions.reasoning_level when resolving the implementer.

Tests: test/llmMetrics.test.ts, test/llmMetricsRecording.test.ts, test/reviewScorePersistence.test.ts, test/reviewScoresMigration.test.ts (add a sibling for the new migration).

Verification: npm run test:prepare, npm run typecheck, node scripts/run-test-suite.mjs <changed test files>, and eslint --max-warnings 0 in each touched package.

Activity

  1. propr-dev commented on Nov 11, 2026

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-5-5
    • Branch: 3430/claude-opus-5-5-record-reasoning-effort-a-20261111-1911-tkn
    • Base Branch: main
    • Worktree: issue-3430-20261111-1911-claude-opus-5-5-tkn

    🔍 Track Task Execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions