Skip to content

feat(mcp): manage disposition metrics via update_agent (PRO-1949) - #31

Merged
prat11m merged 1 commit into
mainfrom
feature/mcp-disposition-metrics
Jul 24, 2026
Merged

feat(mcp): manage disposition metrics via update_agent (PRO-1949)#31
prat11m merged 1 commit into
mainfrom
feature/mcp-disposition-metrics

Conversation

@prat11m

@prat11m prat11m commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What

Adds post-call disposition metric management to the MCP update_agent tool. Previously dispositionMetrics (postCallAnalyticsConfig) was unreachable via MCP — the tool only exposed the free-form callDispositionConfig string.

Two new params on update_agent:

  • add_disposition_metrics[{ identifier, prompt, metric_type, choices? }], upsert by identifier
  • remove_disposition_metrics[identifier]

The backend only supports full-array replace on postCallAnalyticsConfig (no per-metric endpoint), so the tool masks that: it reads the branch's current metrics, applies remove-then-add, and writes the whole array back — preserving summaryPrompt and untouched metrics. Callers just say "+ these / − those".

How

  • Read (draft-aware): readResolvedConfig in versioning.ts uses GET /agent/:id?draftId=|versionId= — the only path that resolves section blocks into a flat config (blocks store section references, not inline content).
  • Validate locally (mirrors backend transformPostCallAnalyticsConfig): identifier ^[a-z0-9_]+$, ENUM requires non-empty choices, no duplicate identifiers — clear errors before the round-trip.
  • Write: full postCallAnalyticsConfig via the existing draft PUT, with expectedRevision passed for optimistic concurrency when a draft is already open (backend 409s on a conflicting analytics-section edit instead of clobbering).
  • get_agent now lists current dispositionMetrics (read from _resolvedConfig, since the agent DTO strips postCallAnalyticsConfig).

Metric shape: { identifier, dispositionMetricPrompt, dispositionMetricType ∈ STRING|BOOLEAN|INTEGER|ENUM|DATETIME, choices? (ENUM) }.

What to test

  • update_agent with add_disposition_metrics (each type; ENUM with/without choices) on a branch → get_branch_draft / test_agent --include_draft shows them.
  • Re-adding an existing identifier updates it (upsert); remove_disposition_metrics drops it.
  • get_agent lists the live metrics.
  • Concurrent edit on an open draft's analytics section surfaces the expectedRevision conflict.

What to validate

  • Draft-aware read on a non-live branch and on a branch with a pre-existing open draft whose analytics differ from head (the one path not yet exercised live).
  • summaryPrompt is preserved when only metrics change.

Env vars

None.

Deployment

Plain merge-deploy (rebuild + redeploy MCP server). No migrations, no config.

Notes

Related backend/PCA bugs tracked in PRO-1949 (weak callDispositionConfig validation, no granular metric API, ...pca passthrough) — out of scope for this PR.

🤖 Generated with Claude Code

Add add_disposition_metrics / remove_disposition_metrics params to
update_agent for post-call disposition metrics (postCallAnalyticsConfig).
The backend only supports full-array replace, so this reads the branch's
current metrics (draft-aware via GET /agent/:id?draftId=|versionId=),
applies remove-then-add (upsert by identifier), validates locally
(identifier format, ENUM needs choices, no dup ids), and writes the full
array back — preserving summaryPrompt and untouched metrics. Passes
expectedRevision for optimistic concurrency when a draft is already open.

get_agent now lists current dispositionMetrics (read from _resolvedConfig,
since the agent DTO strips postCallAnalyticsConfig).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@prat11m
prat11m merged commit 455bb13 into main Jul 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants