Skip to content

conflict_resolver never judges with an Anthropic model: the Anthropic client drops the json_schema response_format #1275

In review

Description

@pauloeduardo

Component

Background workers

Describe what's wrong

With LOOM_CONFLICT_RESOLVER_MODEL set to a Claude model (claude-haiku-5-5 or claude-sonnet-5-5), every conflict_resolver judgement fails with nothing usable in two answers. Each failed judgement still costs two paid model calls.

The resolver passes response_format=cr.RESPONSE_FORMAT, which is {"type": "json_schema", ...}, but AnthropicLLMClient.complete handles only json_object and drops every other format:

# server/llm/anthropic.py (v1.3.0 and main)
json_mode = (response_format or {}).get("type") == "json_object"
if response_format and not json_mode:
    log.debug("anthropic client ignoring response_format=%s", response_format)

SYSTEM_PROMPT in server/memory/domain/conflict_resolution.py says only "Return JSON matching the schema". It does not spell out the schema. Without it, Claude returns a sensible judgement in a different shape: a top-level array whose entries carry id, where parse_verdicts needs {"peers": [{"peer_id": ...}]}. parse_verdicts returns {}, the resolver retries with twice the output cap, gets the same shape back, and raises Unanswered. The row stays owed and is tried again on the next pass, so it keeps spending.

On one local install, 10 rows cost US$0.18 in a single pass with Sonnet, and nothing was judged.

The default gpt-6.1-sol needs an OpenAI key. An install that runs only on Anthropic therefore has no working resolver: the only option is LOOM_MEMORY_CONFLICT_RESOLVER_ENABLED=false.

Does it reproduce on the latest release or main?

Yes

How to reproduce

Settings: LOOM_LLM_PROVIDER=anthropic, LOOM_LLM_MODEL=claude-sonnet-5-5, LOOM_CONFLICT_RESOLVER_MODEL=claude-sonnet-5-5, with ANTHROPIC_API_KEY set. Single-user bundled install. Latest applied migration: 113_oauth_verified_email.sql.

Run inside the loom container (cd /app && python):

import asyncio
from server.llm.client import get_llm_client_without_fallback
from server.memory.domain import conflict_resolution as cr
from server.memory.app.conflict_resolver import REASONING_EFFORT

new = cr.Note("m0", "local/server_version", "The Loom server runs version 1.3.0.", written="2026-11-23")
peers = [
    cr.Note("m1", "local/server_version_old", "The Loom server runs version 1.2.0.", 0.9, written="2026-11-19"),
    cr.Note("m2", "local/loom_port", "Loom listens on port 7777.", 0.6, written="2026-11-19"),
]

async def main():
    llm = get_llm_client_without_fallback("claude-sonnet-5-5", reasoning_effort=REASONING_EFFORT)
    res = await llm.complete(cr.SYSTEM_PROMPT, cr.user_prompt(new, peers),
                             max_tokens=cr.max_output_tokens(len(peers)),
                             response_format=cr.RESPONSE_FORMAT)
    print(res.stop_reason)
    print(res.text)
    print(cr.parse_verdicts(str(res.text), peers))

asyncio.run(main())

Output:

end_turn
[{"id":"p1","reason":"Same entity (Loom server version) and same attribute; NEW states 1.3.0 later than EXISTING's 1.2.0, so EXISTING is outdated.","same_entity":true,"same_attribute":true,"verdict":"update","confidence":0.95},{"id":"p2","reason":"Loom's listening port and the Loom server version are different properties of the same service; both remain true.","same_entity":true,"same_attribute":false,"verdict":"related","confidence":0.9}]
{}

The judgement itself is right. It is lost only because of its shape.

Expected behavior

A resolver model on the Anthropic provider should either produce verdicts that parse_verdicts reads, or be refused up front (ModelUnavailable) instead of paying for answers that are thrown away. conflicts-and-refusal.md presents LOOM_CONFLICT_RESOLVER_MODEL as a free choice of judge.

Possible fixes:

  1. In AnthropicLLMClient, honour json_schema by sending it as a forced tool (tools=[{name, input_schema}], tool_choice={"type": "tool", ...}) or through Anthropic's structured-output parameter, and return the tool input as the text.
  2. Or, more narrowly, state the expected JSON shape in the resolver's SYSTEM_PROMPT, so that providers which do not enforce the schema still return {"peers": [{"peer_id", "reason", "same_entity", "same_attribute", "verdict", "confidence"}]}.

Other callers that pass a json_schema response_format to the Anthropic client are probably affected the same way.

Error message and logs

server.memory.workers.conflict_resolver — conflict_resolver: judged=0 retired=0 flagged=0 cleared=0 skipped_no_action=0 skipped_changed=0 skipped_pinned=0 skipped_budget=0 skipped_behind=0 capped_namespaces=0 errored=10
server.memory.workers.conflict_resolver — conflict_resolver: 10 error(s) this pass: local/<key>: nothing usable in two answers (output cap 420 tokens); local/<key>: nothing usable in two answers (output cap 960 tokens); local/<key>: nothing usable in two answers (output cap 1500 tokens) (+7 more)

Environment

Loom 1.3.0 (images ghcr.io/clickhouse/loom:1.3.0, loom-extractor:1.3.0), bundled Docker Compose stack
ClickHouse 26.10.4.207 (bundled)
LLM provider: anthropic (claude-sonnet-5-5); resolver model tried: claude-haiku-5-5, claude-sonnet-5-5
Embeddings: local (384 dims)
Agent plugin: Claude Code, loom plugin 1.2.41
Host: Linux, single-user, no auth

Related issues and pull requests

Related: #26
Related: #28

How this was found

An AI tool found it, and I have not reproduced it myself

Redaction

  • I removed tokens, keys, passwords and personal or customer data from everything above.

Activity

  1. added
    bug
    help wanted
    up-for-grabs
    on Nov 23, 2026
  2. zlareb1 commented on Nov 23, 2026

    @zlareb1
    Member

    @pauloeduardo would you like to fix this?

  3. pauloeduardo commented on Nov 24, 2026

    @pauloeduardo
    Author

    Yes, I opened #1311 for it.

    The fix is in the Anthropic client rather than the resolver's prompt, so any caller that passes a json_schema format gets it. The schema is sent as the Messages API's structured output (output_config.format, next to the effort), and it is also written into the JSON directive, which keeps the reply in shape if a model refuses output_config.

    I ran the reproduction from this issue against the live API on the branch. parse_verdicts now reads both verdicts on claude-haiku-5-5 and claude-sonnet-5-5, where both returned {} before. CI is waiting for workflow approval, since the PR comes from a fork.

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

Metadata

Metadata

Assignees

Labels

bughelp wantedup-for-grabs

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions