AI Agent Tool Calls Are Correct but the Answer Is Wrong: Closing the Last Mile

    This article examines a common failure mode in AI agents that use spatial perception and geometry tools: the tool returns accurate measurements, yet the final answer is still incorrect. It covers two typical failure patterns, a root-cause breakdown across representation, contracts, workflow, context, and validation layers, and a practical engineering approach based on structured tool outputs, an evidence ledger with mandatory citations, coordinate and unit contracts, a verification loop, observability, and cloud-side support. Developers will find concrete starting steps for turning raw readings into contract-bound evidence so agents use tool results correctly.

    1. The Symptom: Correct Measurements, Wrong Conclusion

    When building AI agents with spatial understanding and tool-calling capabilities, developers often run into a counterintuitive failure: perception and geometry tools return completely accurate measurements, but the final answer is wrong. This is similar to an analyst who holds accurate research data yet reaches the opposite conclusion after overlooking one key metric. The problem is not data collection; it is the reasoning handoff from data to conclusion.

    A research paper on a new generation of spatial agents reviewed the execution traces of a spatial reasoning system and found that the tool calls themselves rarely failed. Failures were concentrated in the handoff between tools and the model. The same issue is common in real applications: an AI coding tool may execute a retrieval correctly but use the returned snippets incorrectly, or a monitoring and alerting system may report accurate metrics that the model interprets with the wrong trend.

    2. Why Spatial Reasoning Is Hard

    Spatial reasoning requires a model to determine the relative positions and movement directions of objects in 3D space, for example, whether a nightstand is to the left or right of a TV, or which direction a target in a video is moving. It is the capability foundation for systems that interact with the physical world, including autonomous driving, home robotics, and industrial quality inspection.

    Early approaches tried to compress 3D knowledge directly into model parameters and relied on large-scale annotation for one-shot prediction. The key weakness was that the model did not actually “measure” the current scene; it depended on training memory. Changing the scene, viewpoint, or perception backend would require retraining. After 2024, an agent-based approach emerged in which the model actively calls 3D perception and geometry tools and repeatedly measures through a “plan-execute-reflect” loop. Representative systems include early spatial agent frameworks and later specialized pipelines designed as state machines. Capability improved significantly, but the handoff defect was overlooked for a long time.

    3. Two Typical Failure Patterns

    The first is “reads correctly, solves incorrectly.” The rotation angle output by a tool is numerically correct, but the model reverses the direction sign; or the value is correct but is interpreted in the wrong coordinate frame, inverting the meaning entirely. The root cause is the lack of an explicit contract for units, axes, sign conventions, and reference frames.

    The second is more subtle: “evidence exists but is not used.” The measurement result is already in the context, yet the model ignores it during final reasoning and falls back to training priors. The root cause is that evidence is not strongly bound to reasoning steps, and key entries are diluted within a long context.

    4. Root-Cause Analysis

    • Representation layer: Tool returns are raw numbers or natural-language fragments, lacking structured fields and metadata.
    • Contract layer: Coordinate frames, units, precision, and confidence are unspecified, leaving the model to guess.
    • Workflow layer: Measurement and decision-making are decoupled, with no enforced “collect evidence first, cite it afterward” order.
    • Context layer: Evidence is scattered across long text, and attention dilution leads to its abandonment.
    • Validation layer: There is no automatic check for citation consistency or sign correctness.

    5. Engineering Solutions

    1) Structured Tool Returns

    Make every call return an object with metadata instead of plain text:

    1. {
    2. "metric": "relative_angle",
    3. "value": 37.5,
    4. "unit": "deg",
    5. "frame": "camera_left_eye",
    6. "axis": "yaw",
    7. "sign_rule": "counterclockwise_positive",
    8. "confidence": 0.93,
    9. "evidence_id": "ev_017"
    10. }

    2) Evidence Ledger and Mandatory Citations

    Maintain an evidence list and require every conclusion in the final answer to be tagged with an evidence_id. Conclusions that do not cite evidence are treated as invalid.

    3) Coordinate Contracts and Unit Normalization

    Fix the reference frame, axes, and sign rules in the system prompt and tool descriptions. When necessary, normalize them at the gateway so the model does not have to infer them on its own.

    4) Verification Loop

    Add self-check steps: sign-flip tests, unit consistency checks, and cross-viewpoint validation. If an inconsistency is found, trigger re-measurement instead of answering directly.

    5) Observability

    Record every tool call, evidence citation, and validation result in structured logs through a logging service, and use monitoring and alerting to locate where “evidence abandonment” and “sign errors” occur.

    6) Cloud-Side General Capabilities

    Object storage can hold trace samples, message queues can decouple measurement from reasoning, container platforms can host the tool gateway, and logging and monitoring systems can provide trace-level visibility, making the last mile measurable and regression-testable.

    6. Results and Recommendations

    In practice, upgrading “raw readings” into “contract-bound evidence objects,” combined with mandatory citations and automatic validation, significantly reduces sign and coordinate errors while cutting down evidence abandonment. Developers are advised to start with three things: define a unified evidence structure, fix coordinate and sign contracts in the prompt, and ship citation consistency validation. Together, these steps move an agent from “can call tools” to “can use tool results correctly,” truly closing the last mile from measurement to conclusion.