Trace an AgentCore session cost spike to one model call
Trace an AgentCore session cost spike to a model span, account for delayed Runtime compute, and verify whether shorter input still returns the right answer.
The support agent returned the right order number, but its AgentCore session cost looks high for a task that only classifies a ticket. Before trimming the prompt, find which call accounts for the estimate. Then check whether the shorter input preserves the answer and whether both sessions include the same kinds of work. A session total can rise after the response even if the model span stays unchanged.
This read-only investigation is for an operator with an existing test agent on AgentCore Runtime and two recorded test runs. You’ll leave with the Session IDs, the corresponding model spans, the early and later estimates, and a decision about which input to keep. The ticket, identifiers, timestamps, token counts, and dollar figures below are illustrative. Use the completed worksheet to rehearse the diagnosis, then substitute values from your own test records.
AWS announced the public preview of cost estimates by session, trace, and span on December 1, 2026, in US West (Oregon), US East (N. Virginia), and US East (Ohio). The example uses Oregon. AWS announcement

Match both sessions to the same ticket
Start with the response records from your test client or harness. You need each actual Session ID, when its session ended, and the response the caller received. Reconstructing the early-to-late change also requires an early estimate recorded while compute was pending. If the sessions have aged and you have only their latest values, compare the current estimates and components and leave the early figures unknown. The current total alone cannot tell you which estimates had arrived when the response came back.
- Confirm the account and Region that contain the test agent. You need access to AgentCore Observability, telemetry produced by the AWS Distro for OpenTelemetry (ADOT), and CloudWatch Transaction Search active for that account and Region. AWS says ADOT is the default on AgentCore Runtime and the managed harness. Transaction Search is configured separately by account and Region, and trace delivery can fail while it is pending. If it is inactive, investigate a pair captured after setup became active. AWS console prerequisites
- Match both invocations to
task:shipping-1042. The expected answer is categoryshippingand order ID1042. Score the actual response in the test record. A natural-language response passes for this case if it unambiguously supplies both values. A successful span tells you the call completed at the telemetry level. The saved response tells you whether the caller received the two values. - Identify the input change. The baseline sent the current ticket plus an archive of unrelated queue handoff notes. The shorter run sent only the current ticket. In the example both used the same agent and endpoint, served model, response instruction, and one-turn classification path. Each run used its own session so the shorter run began without the baseline’s conversation history. Keep the original payload in the test fixture so you can restore it if the shorter input fails.
The shared instruction was Classify the current ticket and return its category and order ID. The complete retained ticket was Current ticket: The parcel for order 1042 has not arrived. Can you check where it is? The omitted archive contained unrelated handoff material such as staffing notes, queue schedules, and resolved cases for other orders. The example assumes that archive is already in the baseline record. The span’s input token count describes the whole recorded model call, including whatever the test agent put around the ticket. Read it from the span even if you know the length of the ticket text.
Use one expected answer for both runs before looking at prices. Shipping issue for order 1042 passes. Shipping issue fails because it omits the number a downstream handler needs. Order 1042 has a billing issue fails because it would send the ticket to the wrong queue. This rule makes it possible to reject a cheaper result even when the model span shows that the call succeeded.
If the saved responses came from different endpoints or models, set them aside as evidence for a different question. An equally correct answer at a lower price could come from a different model or rate. To judge the payload change, identify the same classification operation on the same served model. If the shorter request went through an extra lookup or retry, record that before comparing dollars. One operation can become cheaper while the path used to complete the ticket becomes more expensive. For an experiment that deliberately changes the model, see how to verify that conversation context survives the change. AgentCore model override
Open the trace and isolate the classification span
- In the Amazon Bedrock AgentCore console, open Observability. Set Agent to
support-triage-testand Endpoint toDEFAULTfor this illustrative case. Set Date range to cover the recorded runs on December 2, 2026, from 14:00 to 15:00 UTC. Use your own timestamps and account for the time zone displayed by your console. A wider range can help if a run occurred near a boundary. Still use the Session ID to select the row. AWS cost view guide - Open Sessions. Find the row for the baseline Session ID and read its Total cost. Sorting by Total cost helps surface expensive sessions. Use the identifier from the recorded invocation to select the exact row. Click Session ID. The console switches to Traces with a
Session = <session ID>filter token. The session estimate you recorded came from the Sessions row. - In Traces, sort by Total cost if the session has several turns. Choose the relevant Trace ID and use the trace details panel to select the classification model span. Record its model, input and output tokens, and estimated cost. Read the operation and where it occurs in the turn to verify that you found the classification call. In a session with a retry, the largest value could belong to a different attempt. Record the trace and span identifiers so you can find the same records on a later read. AWS session investigation guide
- Return to Sessions and open the shorter run by its own Session ID. Check that its filter token uses that ID before opening the trace. Find the span that did the same job. Verify the answer against the response record before recording the comparison. Use the model span for the cost of the classification action and the response record for what the caller actually received.
The worksheet is filled with expected observations. Names such as ship-1042-full and classify-a are illustrative labels. In your console, use the actual Session ID and matching trace and span identifiers. The dollar figures are hypothetical USD estimates.
| Input | Action | Expected result |
|---|---|---|
task:shipping-1042 baseline · ship-1042-full · current ticket plus archive · session ended 14:08 UTC |
At 14:13 UTC, open Observability, select support-triage-test and DEFAULT, then open the matching Session ID in Sessions. Choose the matching Trace ID in Traces and select model span classify-a. |
Sessions shows an initial $0.025. The classification span shows $0.025 with 12,000 input and 100 output tokens. The saved answer says shipping, order 1042. Runtime compute is pending. |
task:shipping-1042 shorter input · ship-1042-short · current ticket only · session ended 14:11 UTC |
At 14:16 UTC, use the same scope. Choose the shorter run’s Session ID in Sessions, confirm its Traces filter, then open its classification span classify-b. |
Sessions shows an initial $0.005. The corresponding span shows $0.005 with 2,000 input and 100 output tokens. In the passing example the saved answer still says shipping, order 1042. An answer with order 1044 would fail. Runtime compute is pending. |
| Same passing Session IDs at 14:50 UTC · 42 and 39 minutes after the respective session ends | Reopen both Sessions rows with the same selectors. Compare the later Total cost and verify the same model span values in each trace. | Baseline session $0.029 and shorter session $0.009, with $0.004 of session-level Runtime compute in each. The span estimates remain $0.025 and $0.005. |
The baseline model span alone explains the initial $0.025. In the passing pair, the span difference is $0.020, input tokens fall by 10,000, and output tokens stay at 100. Those observations direct the investigation to what the classification call received. The application record links the larger token count to the archive that was sent. With only the input token count, you can identify the large call, but you still need the request record to determine which part of the payload to remove. Check cache token costs when present. AWS itemizes input and output token costs, and the span total can also include cache tokens. The illustrative pair assumes no cache token charges. AWS cost coverage and limits
On a busier trace, compare by operation before ranking by dollars. For example, if both runs classify the ticket and the shorter run also generates a customer reply, the reply span belongs in the session comparison. It cannot substitute for the classification span when testing the input change. If you cannot identify a corresponding operation in both traces, record that the execution paths differ and limit your finding to the individual calls you can identify.
Explain the later total without charging it to a trace
Runtime CPU and memory time is accounted for over the session’s machine lifetime. It can include time the machine stays warm between turns. AWS records the amount after the machine stops and says it arrives about 15–35 minutes after the session ends. It appears as its own entry at session scope. Reopen the Sessions row after that window even if the trace already shows the full model call. AWS session compute accounting
- Calculate time since each session ended. Use the session end time from your test record. The time when you first saw the model response can be earlier, especially for a session kept warm between turns. The five-minute readings in the worksheet are early readings. The 14:50 UTC readings are beyond the approximate window for both runs.
- Reopen the same Sessions rows. Keep the initial readings with their observation times and add the later readings separately. If Runtime appears and the classification span is unchanged, attribute the additional amount to compute after accounting for the other components. If a separate priced span also appeared between readings, record that amount individually before explaining the difference.
- Use Overview, the Cost graph, and By resource type to see which components dominate for the selected agent and endpoint. AWS says this view cannot be narrowed to one session. For the arithmetic of a single session, use its Total cost and the per-call estimates in its traces, with Runtime accounted for at session scope. AWS component breakdown and scope
| Component in the illustrative comparison | Baseline initial | Baseline later | Shorter initial | Shorter later |
|---|---|---|---|---|
| Classification model span | $0.025 | $0.025 | $0.005 | $0.005 |
| Session-level Runtime compute | Pending | $0.004 | Pending | $0.004 |
| Session Total cost | $0.025 | $0.029 | $0.005 | $0.009 |
No other priced actions appear in the clean pair. For the baseline, adding $0.004 to the model estimate brings the session to $0.029. The shorter run increases by the same amount. Mixing the late baseline with the early shorter run would imply a $0.024 reduction. The worksheet’s late-to-late difference is $0.020. The extra apparent $0.004 comes from comparing one session with compute to another whose compute had yet to arrive.
You can investigate the input from the span while Runtime is pending. Wait for comparable coverage before judging the whole session. If the late totals still differ for reasons beyond the corresponding spans, investigate the extra components individually. A lower classification span estimate can be offset by a larger Runtime entry if the new run stayed alive longer. Use the run timing and trace history to investigate whether the session stayed idle or did extra work. If the totals are close after different components move in opposite directions, keep both figures in the handoff so the span improvement does not get mistaken for a comparable change in the whole session.
Diagnose the dash or the missing span
Start with a concrete action that the application record says happened. A model span you can open has reached Observability. A tool call you cannot find could be missing telemetry, outside the filter, or attached to another session. A pending Runtime entry has a timing explanation and belongs to the session total. Record the symptom first, then follow the check it calls for. AWS guidance on missing and incomplete estimates
| Input | Action | Expected result |
|---|---|---|
task:shipping-1042 · clean baseline · classify-a shows $0.025 with 12,000 input tokens |
Open the model span from the filtered trace and match its operation to the archived test request. | The numeric estimate belongs to an identified call. The request record supports testing removal of unrelated archive material. |
| Same case · baseline at 14:13 UTC · no session-level Runtime compute yet | Recheck the same Sessions row at 14:50 UTC in the same scope and compare it with the previously recorded trace. | Runtime contributes $0.004 at session scope. The original $0.025 model span stays unchanged. |
Alternate task:shipping-1042 run · an extra model span displays a dash · its model has no public price |
Read the span’s model identity and check model and Region pricing eligibility, coverage, and whether cost was set up before the run. | The extra span is visible and unpriced. Record its amount as unknown and withhold a whole-session comparison with the clean baseline. |
Alternate task:shipping-1042 run · a Gateway invocation is recorded by the application but absent under ship-1042-short |
Check that tracing for the resource delivered the span. If it is available in the resource’s telemetry, compare its session.id with the agent span’s session.id and check the calling agent identity. |
The tool span carries ship-1042-other in the example. It cannot roll up under ship-1042-short. Exclude this pair from a whole-session comparison. |
The last two rows are independent variants. The clean pair and chart use the two comparable sessions. For a visible span with a dash, check whether you are looking at a covered dimension. Model input tokens are covered for supported priced models. Runtime instance management fees, data transfer, and Memory storage are examples of dimensions outside the estimate. If the span ran before setup, select a later pair. AWS also says a price missing when the span was recorded is marked unavailable. A newly published price can take about an hour to apply to new work. A persistent model dash needs pricing or coverage evidence of its own. AWS missing-cost troubleshooting · AWS coverage reference
For a missing Gateway span, verify the expected invocation against the test record and check whether the tool resource emitted and delivered a span. Compare the full session.id values once you have the agent and tool records for that work. An agent’s own spans identify the agent with cloud.resource_id. A tool span uses aws.client.cloud.resource_id to identify the calling agent. A matching agent identifier cannot make a different session.id roll up into the desired session. Without the tool telemetry, record that it was absent from the session view and leave the cause unresolved. Give the resource owner the Session ID, tool resource, and invocation time so they can check delivery and identity propagation. AWS attribution rules
If Sessions is empty, revisit the Region, selectors, run time, and Transaction Search status. If the sessions appear but both lack model spans, confirm that telemetry reached Observability before ranking them. If the model spans are present but Runtime remains absent after the approximate window, confirm that the sessions ended and ran on AgentCore Runtime. AWS lists self-hosted compute outside Runtime coverage. For a confirmed Runtime run with unresolved telemetry, mark the session estimate incomplete and scope any finding to the spans you can price. Record which side has the gap, even if the missing entry has no numeric amount.
Decide whether to keep the shorter input
The clean pair supports keeping the shorter input for this fixture. The response record preserves both required values. The corresponding classification span uses the same model and shows a lower estimate. Each session covers the same priced model action and includes a later Runtime compute entry. In your own pair, confirm that the cheaper span still represents the same operation and that the other actions have comparable coverage.
- Keep the shorter input for this case when the answer is still
shippingand1042, the matched span cost falls, and coverage is comparable after the recheck. Record the span difference of $0.020 and the later session estimates of $0.029 and $0.009 in the example. Write down which text was retained so someone can repeat the comparison with the same input boundary. - Restore the baseline input if the shorter run returns
shippingwithout1042, picks another order, or gives the wrong category. Put back the saved original request in the test fixture and discard the pair as evidence of savings on a completed task. If you test a revised input, create a fresh pair with the required facts and verify the response again. The console investigation is read-only. - Withhold the session verdict if a comparable span is missing, unpriced, or attributed to another session, or if compute is still pending on one side. Keep any valid observation scoped to the priced span it describes. Once coverage and attribution are consistent, use a fresh comparable pair if the existing records still contain the gap. Mark which estimate remains incomplete so the next operator knows why it was excluded.
For a queue-wide input rule, add a ticket where an earlier turn carries a required fact. A current message such as Where is it now? could depend on the prior message Please check order 1043. Use shipping and 1043 as its expected answer, retain that earlier message in the baseline, and compare against the proposed restriction. If shortening drops the ID, the response check fails even when the numeric estimate improves. For a worked example of verifying the lookup itself when the tool path changes, see LangSmith Backtesting for a Wrong Order Lookup.
When one version needs a retry, include the extra work in the decision. In this fixture, a first answer without the order ID fails the two-field check even if a later answer repairs it. A follow-up comparison can measure the corrected path, including the action that recovered the missing ID, with both versions scored against the same required result. Cost per completed task
The estimates explain behavior inside AgentCore. AWS uses public rates and excludes invoice reconciliation and discounted rates from this view. If the team needs to charge back work, take the session finding as evidence of which action changed and use the billing records for the financial comparison. AWS estimate limits · Reconcile Before You Charge Back
A filled handoff for the illustrative pair reads as follows. “Both task:shipping-1042 runs returned shipping and order 1042. The classification span fell from $0.025 to $0.005 after the unrelated archive was removed. Both later totals include $0.004 Runtime compute. Keep the shorter input for this fixture.” On a real investigation, attach the Session IDs, matched trace and span records, observation times, and the saved responses to the handoff. That gives the next operator the underlying evidence for the diagnosis and the input decision. AgentOps

