Skip to content

AgentReasoning.callLLM cannot set a cognitive phase, so ad-hoc calls land in ArcTraceProjection's UNKNOWN bucket #685

Description

@wow-miley

Problem

AgentReasoning.callLLM gives a caller no way to tag the invocation with a CognitivePhase.

AgentReasoning.kt:277-282 builds its routing context as:

RoutingContext(agentId, agentRole, requirements, workflowId = runId)

phase is left null. AgentLLMService faithfully propagates that null into the telemetry pair it emits (AgentLLMService.kt:490,526cognitivePhase = routingContext?.phase), and ArcTraceProjection then files the invocation under UNKNOWN (ArcTraceProjection.kt:139,393).

The result: a caller using the convenient entry point gets a trace where the model invocations are real but unattributed. Everything needed to do better is public and one layer down — it just isn't reachable from callLLM.

Why it matters

RoutingContext is a public data class with a settable phase (RoutingContext.kt:34-44), and AgentLLMService is publicly constructible with a call(prompt, systemMessage, …, routingContext) overload (AgentLLMService.kt:71-108,133-140). So the workaround is to bypass AgentReasoning and drive AgentLLMService directly — which works, but means giving up AgentReasoning's conveniences purely to set one field.

Found while scoping Socket's PROPEL trace work (SCKT-525), where Socket needs per-step invocations tagged EXECUTE. Socket is unblocked either way — it can construct AgentLLMService directly — so this is ergonomics, not a blocker. Filing it because the convenient path silently produces worse traces than the inconvenient one, which is the wrong way round.

Suggested change

An additive, default-null phase: CognitivePhase? = null parameter on AgentReasoning.callLLM, threaded into the RoutingContext it already builds. Source- and binary-compatible; no behaviour change when omitted.

Worth a look at whether AgentReasoning should instead default the phase to something more useful than null, given that docs/concepts/propel-loop.md states every model invocation should be phase-tagged.

Acceptance

  • callLLM can set a cognitive phase without dropping to AgentLLMService.
  • An invocation made through callLLM with a phase appears under that phase in ArcTraceProjection, not UNKNOWN.
  • Omitting the parameter behaves exactly as today.

Related

  • SCKT-525 — Socket's PROPEL trace implementation, which is where this surfaced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions