curl https://api.nextmoca.com/v1/context/select \ -H "Authorization: Bearer $NEEDLEPATH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "request_id": "req-2026-09-03-0001", "records": [ { "id": "r-001", "kind": "tool_result", "title": "get_invoice(88231)", "source": "billing-api", "text": "{\"invoice_id\": 88231, \"account\": \"acct_4415\", \"total_cents\": 432000, \"currency\": \"usd\", \"status\": \"open\", \"issued\": \"2026-07-28\", \"due\": \"2026-08-27\", \"line_items\": [{\"sku\": \"NP-USAGE\", \"desc\": \"Metered input tokens, July\", \"qty\": 4800000, \"unit_price_cents\": 0.009}, {\"sku\": \"NP-SUPPORT\", \"desc\": \"Priority support\", \"qty\": 1, \"unit_price_cents\": 49900}]}" }, { "id": "r-002", "kind": "tool_result", "title": "get_account(acct_4415)", "source": "crm-api", "text": "{\"account_id\": \"acct_4415\", \"name\": \"Meridian Analytics\", \"plan\": \"scale\", \"payment_method\": \"card_visa_6411\", \"delinquent\": false, \"since\": \"2025-11-03\", \"owner\": \"dana@meridiananalytics.com\"}" }, { "id": "r-003", "kind": "external_data", "title": "Data retention policy v3", "source": "handbook", "text": "Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility." }, { "id": "r-004", "kind": "external_data", "title": "Refund policy v4, section 2", "source": "handbook", "text": "Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible." }, { "id": "r-005", "kind": "external_data", "title": "Refund policy v4, section 3 (exceptions)", "source": "handbook", "text": "Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead'\''s discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered." }, { "id": "r-006", "kind": "tool_result", "title": "get_usage(acct_4415, july)", "source": "metering-api", "text": "{\"account_id\": \"acct_4415\", \"period\": \"2026-07\", \"input_tokens\": 4800000, \"requests\": 1210, \"stand_downs\": 34, \"charged_tokens\": 4646000}" }, { "id": "r-007", "kind": "tool_result", "title": "get_open_tickets(acct_9902)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5488\", \"subject\": \"API key rotation question\", \"opened\": \"2026-08-02\", \"status\": \"closed\", \"assignee\": \"support-lead-1\"}]}" }, { "id": "r-008", "kind": "user_input", "title": null, "source": null, "text": "Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?" }, { "id": "r-009", "kind": "external_data", "title": "Credit policy v2", "source": "handbook", "text": "Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner'\''s written acknowledgement of the cause." }, { "id": "r-012", "kind": "tool_result", "title": "get_key_traffic(acct_4415, 2026-07-01..2026-07-19)", "source": "metering-api", "text": "{\"keys\": [{\"key_id\": \"np_key_a1\", \"requests\": 980, \"user_agent\": \"meridian-batch/2.1\", \"tokens\": 3100000}, {\"key_id\": \"np_key_b2\", \"requests\": 230, \"user_agent\": \"meridian-app/1.4\", \"tokens\": 1700000}], \"note\": \"np_key_a1 traffic stops 2026-07-19T14:02Z\"}" }, { "id": "r-013", "kind": "external_data", "title": "Q2 headcount planning notes", "source": "internal-ops", "text": "The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3." }, { "id": "r-014", "kind": "tool_result", "title": "get_invoice(55102)", "source": "billing-api", "text": "{\"invoice_id\": 55102, \"account\": \"acct_2210\", \"total_cents\": 18900, \"currency\": \"usd\", \"status\": \"paid\", \"issued\": \"2026-07-15\", \"due\": \"2026-08-14\"}" }, { "id": "r-015", "kind": "external_data", "title": "Q3 marketing newsletter draft", "source": "marketing", "text": "Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September." }, { "id": "r-016", "kind": "external_data", "title": "Office move logistics", "source": "internal-ops", "text": "The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes." }, { "id": "r-017", "kind": "tool_result", "title": "get_open_tickets(acct_4415)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5521\", \"subject\": \"July usage dispute\", \"opened\": \"2026-08-05\", \"status\": \"open\", \"assignee\": \"support-lead-2\"}]}" }, { "id": "r-018", "kind": "tool_result", "title": "get_open_tickets(acct_2210)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5502\", \"subject\": \"Login issue after SSO migration\", \"opened\": \"2026-08-01\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}" }, { "id": "r-019", "kind": "external_data", "title": "Vacation and PTO policy", "source": "handbook", "text": "Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect." }, { "id": "r-020", "kind": "external_data", "title": "Runbook: rotating a compromised API key", "source": "ops-wiki", "text": "If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes." }, { "id": "r-021", "kind": "llm_response", "text": "I'\''ve pulled up account acct_4415 and I'\''m reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown." }, { "id": "r-022", "kind": "external_data", "title": "Customer advisory board Q4 invite draft", "source": "marketing", "text": "Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support." }, { "id": "r-023", "kind": "tool_result", "title": "get_account(acct_9902)", "source": "crm-api", "text": "{\"account_id\": \"acct_9902\", \"name\": \"Colby Fixtures\", \"plan\": \"growth\", \"payment_method\": \"card_mc_2290\", \"delinquent\": false, \"since\": \"2026-01-14\", \"owner\": \"ops@colbyfixtures.com\"}" }, { "id": "r-026", "kind": "tool_result", "title": "get_open_tickets(acct_5511)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5510\", \"subject\": \"Feature request: CSV export for usage analytics\", \"opened\": \"2026-08-03\", \"status\": \"open\", \"assignee\": \"support-lead-1\"}]}" }, { "id": "r-027", "kind": "external_data", "title": "Q3 all-hands agenda", "source": "internal-ops", "text": "Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live." }, { "id": "r-029", "kind": "external_data", "title": "Marketing site refresh, visual only", "source": "marketing", "text": "The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only." }, { "id": "r-031", "kind": "tool_result", "title": "get_open_tickets(acct_6630)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5477\", \"subject\": \"Onboarding walkthrough request\", \"opened\": \"2026-07-30\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}" }, { "id": "r-032", "kind": "external_data", "title": "On-call rotation for September", "source": "internal-ops", "text": "September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead." }, { "id": "r-033", "kind": "external_data", "title": "Partner co-marketing webinar recap", "source": "marketing", "text": "Tuesday'\''s co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week." }, { "id": "r-034", "kind": "external_data", "title": "Conference room booking policy", "source": "handbook", "text": "Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing." }, { "id": "r-035", "kind": "external_data", "title": "Blog editorial calendar, Q4", "source": "marketing", "text": "Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication." }, { "id": "r-036", "kind": "external_data", "title": "Kitchen and supplies restock schedule", "source": "internal-ops", "text": "Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week." } ], "task": { "prompt": "What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?", "tool_name": "resolve_billing_dispute" }, "budget": { "max_context_tokens": 900, "operating_point": "np-2026-08-r4" }, "render": true, "render_format": "plain", "return_per_record": true}'
import os
import requests
payload = {
"request_id": "req-2026-09-03-0001",
"records": [
{
"id": "r-001",
"kind": "tool_result",
"title": "get_invoice(88231)",
"source": "billing-api",
"text": "{\"invoice_id\": 88231, \"account\": \"acct_4415\", \"total_cents\": 432000, \"currency\": \"usd\", \"status\": \"open\", \"issued\": \"2026-07-28\", \"due\": \"2026-08-27\", \"line_items\": [{\"sku\": \"NP-USAGE\", \"desc\": \"Metered input tokens, July\", \"qty\": 4800000, \"unit_price_cents\": 0.009}, {\"sku\": \"NP-SUPPORT\", \"desc\": \"Priority support\", \"qty\": 1, \"unit_price_cents\": 49900}]}",
},
{
"id": "r-002",
"kind": "tool_result",
"title": "get_account(acct_4415)",
"source": "crm-api",
"text": "{\"account_id\": \"acct_4415\", \"name\": \"Meridian Analytics\", \"plan\": \"scale\", \"payment_method\": \"card_visa_6411\", \"delinquent\": false, \"since\": \"2025-11-03\", \"owner\": \"dana@meridiananalytics.com\"}",
},
{
"id": "r-003",
"kind": "external_data",
"title": "Data retention policy v3",
"source": "handbook",
"text": "Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.",
},
{
"id": "r-004",
"kind": "external_data",
"title": "Refund policy v4, section 2",
"source": "handbook",
"text": "Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.",
},
{
"id": "r-005",
"kind": "external_data",
"title": "Refund policy v4, section 3 (exceptions)",
"source": "handbook",
"text": "Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.",
},
{
"id": "r-006",
"kind": "tool_result",
"title": "get_usage(acct_4415, july)",
"source": "metering-api",
"text": "{\"account_id\": \"acct_4415\", \"period\": \"2026-07\", \"input_tokens\": 4800000, \"requests\": 1210, \"stand_downs\": 34, \"charged_tokens\": 4646000}",
},
{
"id": "r-007",
"kind": "tool_result",
"title": "get_open_tickets(acct_9902)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5488\", \"subject\": \"API key rotation question\", \"opened\": \"2026-08-02\", \"status\": \"closed\", \"assignee\": \"support-lead-1\"}]}",
},
{
"id": "r-008",
"kind": "user_input",
"title": None,
"source": None,
"text": "Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?",
},
{
"id": "r-009",
"kind": "external_data",
"title": "Credit policy v2",
"source": "handbook",
"text": "Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.",
},
{
"id": "r-012",
"kind": "tool_result",
"title": "get_key_traffic(acct_4415, 2026-07-01..2026-07-19)",
"source": "metering-api",
"text": "{\"keys\": [{\"key_id\": \"np_key_a1\", \"requests\": 980, \"user_agent\": \"meridian-batch/2.1\", \"tokens\": 3100000}, {\"key_id\": \"np_key_b2\", \"requests\": 230, \"user_agent\": \"meridian-app/1.4\", \"tokens\": 1700000}], \"note\": \"np_key_a1 traffic stops 2026-07-19T14:02Z\"}",
},
{
"id": "r-013",
"kind": "external_data",
"title": "Q2 headcount planning notes",
"source": "internal-ops",
"text": "The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.",
},
{
"id": "r-014",
"kind": "tool_result",
"title": "get_invoice(55102)",
"source": "billing-api",
"text": "{\"invoice_id\": 55102, \"account\": \"acct_2210\", \"total_cents\": 18900, \"currency\": \"usd\", \"status\": \"paid\", \"issued\": \"2026-07-15\", \"due\": \"2026-08-14\"}",
},
{
"id": "r-015",
"kind": "external_data",
"title": "Q3 marketing newsletter draft",
"source": "marketing",
"text": "Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.",
},
{
"id": "r-016",
"kind": "external_data",
"title": "Office move logistics",
"source": "internal-ops",
"text": "The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.",
},
{
"id": "r-017",
"kind": "tool_result",
"title": "get_open_tickets(acct_4415)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5521\", \"subject\": \"July usage dispute\", \"opened\": \"2026-08-05\", \"status\": \"open\", \"assignee\": \"support-lead-2\"}]}",
},
{
"id": "r-018",
"kind": "tool_result",
"title": "get_open_tickets(acct_2210)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5502\", \"subject\": \"Login issue after SSO migration\", \"opened\": \"2026-08-01\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}",
},
{
"id": "r-019",
"kind": "external_data",
"title": "Vacation and PTO policy",
"source": "handbook",
"text": "Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.",
},
{
"id": "r-020",
"kind": "external_data",
"title": "Runbook: rotating a compromised API key",
"source": "ops-wiki",
"text": "If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.",
},
{
"id": "r-021",
"kind": "llm_response",
"text": "I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.",
},
{
"id": "r-022",
"kind": "external_data",
"title": "Customer advisory board Q4 invite draft",
"source": "marketing",
"text": "Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.",
},
{
"id": "r-023",
"kind": "tool_result",
"title": "get_account(acct_9902)",
"source": "crm-api",
"text": "{\"account_id\": \"acct_9902\", \"name\": \"Colby Fixtures\", \"plan\": \"growth\", \"payment_method\": \"card_mc_2290\", \"delinquent\": false, \"since\": \"2026-01-14\", \"owner\": \"ops@colbyfixtures.com\"}",
},
{
"id": "r-026",
"kind": "tool_result",
"title": "get_open_tickets(acct_5511)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5510\", \"subject\": \"Feature request: CSV export for usage analytics\", \"opened\": \"2026-08-03\", \"status\": \"open\", \"assignee\": \"support-lead-1\"}]}",
},
{
"id": "r-027",
"kind": "external_data",
"title": "Q3 all-hands agenda",
"source": "internal-ops",
"text": "Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.",
},
{
"id": "r-029",
"kind": "external_data",
"title": "Marketing site refresh, visual only",
"source": "marketing",
"text": "The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.",
},
{
"id": "r-031",
"kind": "tool_result",
"title": "get_open_tickets(acct_6630)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5477\", \"subject\": \"Onboarding walkthrough request\", \"opened\": \"2026-07-30\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}",
},
{
"id": "r-032",
"kind": "external_data",
"title": "On-call rotation for September",
"source": "internal-ops",
"text": "September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.",
},
{
"id": "r-033",
"kind": "external_data",
"title": "Partner co-marketing webinar recap",
"source": "marketing",
"text": "Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.",
},
{
"id": "r-034",
"kind": "external_data",
"title": "Conference room booking policy",
"source": "handbook",
"text": "Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.",
},
{
"id": "r-035",
"kind": "external_data",
"title": "Blog editorial calendar, Q4",
"source": "marketing",
"text": "Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.",
},
{
"id": "r-036",
"kind": "external_data",
"title": "Kitchen and supplies restock schedule",
"source": "internal-ops",
"text": "Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.",
},
],
"task": {
"prompt": "What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?",
"tool_name": "resolve_billing_dispute",
},
"budget": {
"max_context_tokens": 900,
"operating_point": "np-2026-08-r4",
},
"render": True,
"render_format": "plain",
"return_per_record": True,
}
r = requests.post(
"https://api.nextmoca.com/v1/context/select",
headers={"Authorization": f"Bearer {os.environ['NEEDLEPATH_API_KEY']}"},
json=payload,
timeout=10,
)
r.raise_for_status()
result = r.json()
print(result["records_selected"], "selected,", result["tokens_saved"], "tokens saved")
const payload = {
"request_id": "req-2026-09-03-0001",
"records": [
{
"id": "r-001",
"kind": "tool_result",
"title": "get_invoice(88231)",
"source": "billing-api",
"text": "{\"invoice_id\": 88231, \"account\": \"acct_4415\", \"total_cents\": 432000, \"currency\": \"usd\", \"status\": \"open\", \"issued\": \"2026-07-28\", \"due\": \"2026-08-27\", \"line_items\": [{\"sku\": \"NP-USAGE\", \"desc\": \"Metered input tokens, July\", \"qty\": 4800000, \"unit_price_cents\": 0.009}, {\"sku\": \"NP-SUPPORT\", \"desc\": \"Priority support\", \"qty\": 1, \"unit_price_cents\": 49900}]}"
},
{
"id": "r-002",
"kind": "tool_result",
"title": "get_account(acct_4415)",
"source": "crm-api",
"text": "{\"account_id\": \"acct_4415\", \"name\": \"Meridian Analytics\", \"plan\": \"scale\", \"payment_method\": \"card_visa_6411\", \"delinquent\": false, \"since\": \"2025-11-03\", \"owner\": \"dana@meridiananalytics.com\"}"
},
{
"id": "r-003",
"kind": "external_data",
"title": "Data retention policy v3",
"source": "handbook",
"text": "Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility."
},
{
"id": "r-004",
"kind": "external_data",
"title": "Refund policy v4, section 2",
"source": "handbook",
"text": "Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible."
},
{
"id": "r-005",
"kind": "external_data",
"title": "Refund policy v4, section 3 (exceptions)",
"source": "handbook",
"text": "Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered."
},
{
"id": "r-006",
"kind": "tool_result",
"title": "get_usage(acct_4415, july)",
"source": "metering-api",
"text": "{\"account_id\": \"acct_4415\", \"period\": \"2026-07\", \"input_tokens\": 4800000, \"requests\": 1210, \"stand_downs\": 34, \"charged_tokens\": 4646000}"
},
{
"id": "r-007",
"kind": "tool_result",
"title": "get_open_tickets(acct_9902)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5488\", \"subject\": \"API key rotation question\", \"opened\": \"2026-08-02\", \"status\": \"closed\", \"assignee\": \"support-lead-1\"}]}"
},
{
"id": "r-008",
"kind": "user_input",
"title": null,
"source": null,
"text": "Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?"
},
{
"id": "r-009",
"kind": "external_data",
"title": "Credit policy v2",
"source": "handbook",
"text": "Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause."
},
{
"id": "r-012",
"kind": "tool_result",
"title": "get_key_traffic(acct_4415, 2026-07-01..2026-07-19)",
"source": "metering-api",
"text": "{\"keys\": [{\"key_id\": \"np_key_a1\", \"requests\": 980, \"user_agent\": \"meridian-batch/2.1\", \"tokens\": 3100000}, {\"key_id\": \"np_key_b2\", \"requests\": 230, \"user_agent\": \"meridian-app/1.4\", \"tokens\": 1700000}], \"note\": \"np_key_a1 traffic stops 2026-07-19T14:02Z\"}"
},
{
"id": "r-013",
"kind": "external_data",
"title": "Q2 headcount planning notes",
"source": "internal-ops",
"text": "The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3."
},
{
"id": "r-014",
"kind": "tool_result",
"title": "get_invoice(55102)",
"source": "billing-api",
"text": "{\"invoice_id\": 55102, \"account\": \"acct_2210\", \"total_cents\": 18900, \"currency\": \"usd\", \"status\": \"paid\", \"issued\": \"2026-07-15\", \"due\": \"2026-08-14\"}"
},
{
"id": "r-015",
"kind": "external_data",
"title": "Q3 marketing newsletter draft",
"source": "marketing",
"text": "Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September."
},
{
"id": "r-016",
"kind": "external_data",
"title": "Office move logistics",
"source": "internal-ops",
"text": "The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes."
},
{
"id": "r-017",
"kind": "tool_result",
"title": "get_open_tickets(acct_4415)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5521\", \"subject\": \"July usage dispute\", \"opened\": \"2026-08-05\", \"status\": \"open\", \"assignee\": \"support-lead-2\"}]}"
},
{
"id": "r-018",
"kind": "tool_result",
"title": "get_open_tickets(acct_2210)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5502\", \"subject\": \"Login issue after SSO migration\", \"opened\": \"2026-08-01\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}"
},
{
"id": "r-019",
"kind": "external_data",
"title": "Vacation and PTO policy",
"source": "handbook",
"text": "Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect."
},
{
"id": "r-020",
"kind": "external_data",
"title": "Runbook: rotating a compromised API key",
"source": "ops-wiki",
"text": "If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes."
},
{
"id": "r-021",
"kind": "llm_response",
"text": "I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown."
},
{
"id": "r-022",
"kind": "external_data",
"title": "Customer advisory board Q4 invite draft",
"source": "marketing",
"text": "Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support."
},
{
"id": "r-023",
"kind": "tool_result",
"title": "get_account(acct_9902)",
"source": "crm-api",
"text": "{\"account_id\": \"acct_9902\", \"name\": \"Colby Fixtures\", \"plan\": \"growth\", \"payment_method\": \"card_mc_2290\", \"delinquent\": false, \"since\": \"2026-01-14\", \"owner\": \"ops@colbyfixtures.com\"}"
},
{
"id": "r-026",
"kind": "tool_result",
"title": "get_open_tickets(acct_5511)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5510\", \"subject\": \"Feature request: CSV export for usage analytics\", \"opened\": \"2026-08-03\", \"status\": \"open\", \"assignee\": \"support-lead-1\"}]}"
},
{
"id": "r-027",
"kind": "external_data",
"title": "Q3 all-hands agenda",
"source": "internal-ops",
"text": "Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live."
},
{
"id": "r-029",
"kind": "external_data",
"title": "Marketing site refresh, visual only",
"source": "marketing",
"text": "The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only."
},
{
"id": "r-031",
"kind": "tool_result",
"title": "get_open_tickets(acct_6630)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5477\", \"subject\": \"Onboarding walkthrough request\", \"opened\": \"2026-07-30\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}"
},
{
"id": "r-032",
"kind": "external_data",
"title": "On-call rotation for September",
"source": "internal-ops",
"text": "September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead."
},
{
"id": "r-033",
"kind": "external_data",
"title": "Partner co-marketing webinar recap",
"source": "marketing",
"text": "Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week."
},
{
"id": "r-034",
"kind": "external_data",
"title": "Conference room booking policy",
"source": "handbook",
"text": "Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing."
},
{
"id": "r-035",
"kind": "external_data",
"title": "Blog editorial calendar, Q4",
"source": "marketing",
"text": "Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication."
},
{
"id": "r-036",
"kind": "external_data",
"title": "Kitchen and supplies restock schedule",
"source": "internal-ops",
"text": "Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week."
}
],
"task": {
"prompt": "What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?",
"tool_name": "resolve_billing_dispute"
},
"budget": {
"max_context_tokens": 900,
"operating_point": "np-2026-08-r4"
},
"render": true,
"render_format": "plain",
"return_per_record": true
};
const res = await fetch("https://api.nextmoca.com/v1/context/select", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.NEEDLEPATH_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
const result = await res.json();
console.log(result.records_selected, "selected,", result.tokens_saved, "tokens saved");
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
request_id: 'req-2026-09-03-0001',
records: [
{
id: 'r-001',
kind: 'tool_result',
title: 'get_invoice(88231)',
source: 'billing-api',
text: '{"invoice_id": 88231, "account": "acct_4415", "total_cents": 432000, "currency": "usd", "status": "open", "issued": "2026-07-28", "due": "2026-08-27", "line_items": [{"sku": "NP-USAGE", "desc": "Metered input tokens, July", "qty": 4800000, "unit_price_cents": 0.009}, {"sku": "NP-SUPPORT", "desc": "Priority support", "qty": 1, "unit_price_cents": 49900}]}'
},
{
id: 'r-002',
kind: 'tool_result',
title: 'get_account(acct_4415)',
source: 'crm-api',
text: '{"account_id": "acct_4415", "name": "Meridian Analytics", "plan": "scale", "payment_method": "card_visa_6411", "delinquent": false, "since": "2025-11-03", "owner": "dana@meridiananalytics.com"}'
},
{
id: 'r-003',
kind: 'external_data',
title: 'Data retention policy v3',
source: 'handbook',
text: 'Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.'
},
{
id: 'r-004',
kind: 'external_data',
title: 'Refund policy v4, section 2',
source: 'handbook',
text: 'Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.'
},
{
id: 'r-005',
kind: 'external_data',
title: 'Refund policy v4, section 3 (exceptions)',
source: 'handbook',
text: 'Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead\'s discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.'
},
{
id: 'r-006',
kind: 'tool_result',
title: 'get_usage(acct_4415, july)',
source: 'metering-api',
text: '{"account_id": "acct_4415", "period": "2026-07", "input_tokens": 4800000, "requests": 1210, "stand_downs": 34, "charged_tokens": 4646000}'
},
{
id: 'r-007',
kind: 'tool_result',
title: 'get_open_tickets(acct_9902)',
source: 'support-api',
text: '{"tickets": [{"id": "T-5488", "subject": "API key rotation question", "opened": "2026-08-02", "status": "closed", "assignee": "support-lead-1"}]}'
},
{
id: 'r-008',
kind: 'user_input',
title: null,
source: null,
text: 'Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?'
},
{
id: 'r-009',
kind: 'external_data',
title: 'Credit policy v2',
source: 'handbook',
text: 'Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner\'s written acknowledgement of the cause.'
},
{
id: 'r-012',
kind: 'tool_result',
title: 'get_key_traffic(acct_4415, 2026-07-01..2026-07-19)',
source: 'metering-api',
text: '{"keys": [{"key_id": "np_key_a1", "requests": 980, "user_agent": "meridian-batch/2.1", "tokens": 3100000}, {"key_id": "np_key_b2", "requests": 230, "user_agent": "meridian-app/1.4", "tokens": 1700000}], "note": "np_key_a1 traffic stops 2026-07-19T14:02Z"}'
},
{
id: 'r-013',
kind: 'external_data',
title: 'Q2 headcount planning notes',
source: 'internal-ops',
text: 'The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.'
},
{
id: 'r-014',
kind: 'tool_result',
title: 'get_invoice(55102)',
source: 'billing-api',
text: '{"invoice_id": 55102, "account": "acct_2210", "total_cents": 18900, "currency": "usd", "status": "paid", "issued": "2026-07-15", "due": "2026-08-14"}'
},
{
id: 'r-015',
kind: 'external_data',
title: 'Q3 marketing newsletter draft',
source: 'marketing',
text: 'Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.'
},
{
id: 'r-016',
kind: 'external_data',
title: 'Office move logistics',
source: 'internal-ops',
text: 'The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.'
},
{
id: 'r-017',
kind: 'tool_result',
title: 'get_open_tickets(acct_4415)',
source: 'support-api',
text: '{"tickets": [{"id": "T-5521", "subject": "July usage dispute", "opened": "2026-08-05", "status": "open", "assignee": "support-lead-2"}]}'
},
{
id: 'r-018',
kind: 'tool_result',
title: 'get_open_tickets(acct_2210)',
source: 'support-api',
text: '{"tickets": [{"id": "T-5502", "subject": "Login issue after SSO migration", "opened": "2026-08-01", "status": "closed", "assignee": "support-lead-3"}]}'
},
{
id: 'r-019',
kind: 'external_data',
title: 'Vacation and PTO policy',
source: 'handbook',
text: 'Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.'
},
{
id: 'r-020',
kind: 'external_data',
title: 'Runbook: rotating a compromised API key',
source: 'ops-wiki',
text: 'If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.'
},
{
id: 'r-021',
kind: 'llm_response',
text: 'I\'ve pulled up account acct_4415 and I\'m reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.'
},
{
id: 'r-022',
kind: 'external_data',
title: 'Customer advisory board Q4 invite draft',
source: 'marketing',
text: 'Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.'
},
{
id: 'r-023',
kind: 'tool_result',
title: 'get_account(acct_9902)',
source: 'crm-api',
text: '{"account_id": "acct_9902", "name": "Colby Fixtures", "plan": "growth", "payment_method": "card_mc_2290", "delinquent": false, "since": "2026-01-14", "owner": "ops@colbyfixtures.com"}'
},
{
id: 'r-026',
kind: 'tool_result',
title: 'get_open_tickets(acct_5511)',
source: 'support-api',
text: '{"tickets": [{"id": "T-5510", "subject": "Feature request: CSV export for usage analytics", "opened": "2026-08-03", "status": "open", "assignee": "support-lead-1"}]}'
},
{
id: 'r-027',
kind: 'external_data',
title: 'Q3 all-hands agenda',
source: 'internal-ops',
text: 'Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.'
},
{
id: 'r-029',
kind: 'external_data',
title: 'Marketing site refresh, visual only',
source: 'marketing',
text: 'The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.'
},
{
id: 'r-031',
kind: 'tool_result',
title: 'get_open_tickets(acct_6630)',
source: 'support-api',
text: '{"tickets": [{"id": "T-5477", "subject": "Onboarding walkthrough request", "opened": "2026-07-30", "status": "closed", "assignee": "support-lead-3"}]}'
},
{
id: 'r-032',
kind: 'external_data',
title: 'On-call rotation for September',
source: 'internal-ops',
text: 'September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.'
},
{
id: 'r-033',
kind: 'external_data',
title: 'Partner co-marketing webinar recap',
source: 'marketing',
text: 'Tuesday\'s co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.'
},
{
id: 'r-034',
kind: 'external_data',
title: 'Conference room booking policy',
source: 'handbook',
text: 'Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.'
},
{
id: 'r-035',
kind: 'external_data',
title: 'Blog editorial calendar, Q4',
source: 'marketing',
text: 'Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.'
},
{
id: 'r-036',
kind: 'external_data',
title: 'Kitchen and supplies restock schedule',
source: 'internal-ops',
text: 'Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.'
}
],
task: {
prompt: 'What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?',
tool_name: 'resolve_billing_dispute'
},
budget: {max_context_tokens: 900, operating_point: 'np-2026-08-r4'},
render: true,
render_format: 'plain',
return_per_record: true
})
};
fetch('https://api.nextmoca.com/v1/context/select', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nextmoca.com/v1/context/select",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'request_id' => 'req-2026-09-03-0001',
'records' => [
[
'id' => 'r-001',
'kind' => 'tool_result',
'title' => 'get_invoice(88231)',
'source' => 'billing-api',
'text' => '{"invoice_id": 88231, "account": "acct_4415", "total_cents": 432000, "currency": "usd", "status": "open", "issued": "2026-07-28", "due": "2026-08-27", "line_items": [{"sku": "NP-USAGE", "desc": "Metered input tokens, July", "qty": 4800000, "unit_price_cents": 0.009}, {"sku": "NP-SUPPORT", "desc": "Priority support", "qty": 1, "unit_price_cents": 49900}]}'
],
[
'id' => 'r-002',
'kind' => 'tool_result',
'title' => 'get_account(acct_4415)',
'source' => 'crm-api',
'text' => '{"account_id": "acct_4415", "name": "Meridian Analytics", "plan": "scale", "payment_method": "card_visa_6411", "delinquent": false, "since": "2025-11-03", "owner": "dana@meridiananalytics.com"}'
],
[
'id' => 'r-003',
'kind' => 'external_data',
'title' => 'Data retention policy v3',
'source' => 'handbook',
'text' => 'Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.'
],
[
'id' => 'r-004',
'kind' => 'external_data',
'title' => 'Refund policy v4, section 2',
'source' => 'handbook',
'text' => 'Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.'
],
[
'id' => 'r-005',
'kind' => 'external_data',
'title' => 'Refund policy v4, section 3 (exceptions)',
'source' => 'handbook',
'text' => 'Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead\'s discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.'
],
[
'id' => 'r-006',
'kind' => 'tool_result',
'title' => 'get_usage(acct_4415, july)',
'source' => 'metering-api',
'text' => '{"account_id": "acct_4415", "period": "2026-07", "input_tokens": 4800000, "requests": 1210, "stand_downs": 34, "charged_tokens": 4646000}'
],
[
'id' => 'r-007',
'kind' => 'tool_result',
'title' => 'get_open_tickets(acct_9902)',
'source' => 'support-api',
'text' => '{"tickets": [{"id": "T-5488", "subject": "API key rotation question", "opened": "2026-08-02", "status": "closed", "assignee": "support-lead-1"}]}'
],
[
'id' => 'r-008',
'kind' => 'user_input',
'title' => null,
'source' => null,
'text' => 'Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?'
],
[
'id' => 'r-009',
'kind' => 'external_data',
'title' => 'Credit policy v2',
'source' => 'handbook',
'text' => 'Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner\'s written acknowledgement of the cause.'
],
[
'id' => 'r-012',
'kind' => 'tool_result',
'title' => 'get_key_traffic(acct_4415, 2026-07-01..2026-07-19)',
'source' => 'metering-api',
'text' => '{"keys": [{"key_id": "np_key_a1", "requests": 980, "user_agent": "meridian-batch/2.1", "tokens": 3100000}, {"key_id": "np_key_b2", "requests": 230, "user_agent": "meridian-app/1.4", "tokens": 1700000}], "note": "np_key_a1 traffic stops 2026-07-19T14:02Z"}'
],
[
'id' => 'r-013',
'kind' => 'external_data',
'title' => 'Q2 headcount planning notes',
'source' => 'internal-ops',
'text' => 'The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.'
],
[
'id' => 'r-014',
'kind' => 'tool_result',
'title' => 'get_invoice(55102)',
'source' => 'billing-api',
'text' => '{"invoice_id": 55102, "account": "acct_2210", "total_cents": 18900, "currency": "usd", "status": "paid", "issued": "2026-07-15", "due": "2026-08-14"}'
],
[
'id' => 'r-015',
'kind' => 'external_data',
'title' => 'Q3 marketing newsletter draft',
'source' => 'marketing',
'text' => 'Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.'
],
[
'id' => 'r-016',
'kind' => 'external_data',
'title' => 'Office move logistics',
'source' => 'internal-ops',
'text' => 'The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.'
],
[
'id' => 'r-017',
'kind' => 'tool_result',
'title' => 'get_open_tickets(acct_4415)',
'source' => 'support-api',
'text' => '{"tickets": [{"id": "T-5521", "subject": "July usage dispute", "opened": "2026-08-05", "status": "open", "assignee": "support-lead-2"}]}'
],
[
'id' => 'r-018',
'kind' => 'tool_result',
'title' => 'get_open_tickets(acct_2210)',
'source' => 'support-api',
'text' => '{"tickets": [{"id": "T-5502", "subject": "Login issue after SSO migration", "opened": "2026-08-01", "status": "closed", "assignee": "support-lead-3"}]}'
],
[
'id' => 'r-019',
'kind' => 'external_data',
'title' => 'Vacation and PTO policy',
'source' => 'handbook',
'text' => 'Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.'
],
[
'id' => 'r-020',
'kind' => 'external_data',
'title' => 'Runbook: rotating a compromised API key',
'source' => 'ops-wiki',
'text' => 'If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.'
],
[
'id' => 'r-021',
'kind' => 'llm_response',
'text' => 'I\'ve pulled up account acct_4415 and I\'m reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.'
],
[
'id' => 'r-022',
'kind' => 'external_data',
'title' => 'Customer advisory board Q4 invite draft',
'source' => 'marketing',
'text' => 'Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.'
],
[
'id' => 'r-023',
'kind' => 'tool_result',
'title' => 'get_account(acct_9902)',
'source' => 'crm-api',
'text' => '{"account_id": "acct_9902", "name": "Colby Fixtures", "plan": "growth", "payment_method": "card_mc_2290", "delinquent": false, "since": "2026-01-14", "owner": "ops@colbyfixtures.com"}'
],
[
'id' => 'r-026',
'kind' => 'tool_result',
'title' => 'get_open_tickets(acct_5511)',
'source' => 'support-api',
'text' => '{"tickets": [{"id": "T-5510", "subject": "Feature request: CSV export for usage analytics", "opened": "2026-08-03", "status": "open", "assignee": "support-lead-1"}]}'
],
[
'id' => 'r-027',
'kind' => 'external_data',
'title' => 'Q3 all-hands agenda',
'source' => 'internal-ops',
'text' => 'Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.'
],
[
'id' => 'r-029',
'kind' => 'external_data',
'title' => 'Marketing site refresh, visual only',
'source' => 'marketing',
'text' => 'The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.'
],
[
'id' => 'r-031',
'kind' => 'tool_result',
'title' => 'get_open_tickets(acct_6630)',
'source' => 'support-api',
'text' => '{"tickets": [{"id": "T-5477", "subject": "Onboarding walkthrough request", "opened": "2026-07-30", "status": "closed", "assignee": "support-lead-3"}]}'
],
[
'id' => 'r-032',
'kind' => 'external_data',
'title' => 'On-call rotation for September',
'source' => 'internal-ops',
'text' => 'September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.'
],
[
'id' => 'r-033',
'kind' => 'external_data',
'title' => 'Partner co-marketing webinar recap',
'source' => 'marketing',
'text' => 'Tuesday\'s co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.'
],
[
'id' => 'r-034',
'kind' => 'external_data',
'title' => 'Conference room booking policy',
'source' => 'handbook',
'text' => 'Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.'
],
[
'id' => 'r-035',
'kind' => 'external_data',
'title' => 'Blog editorial calendar, Q4',
'source' => 'marketing',
'text' => 'Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.'
],
[
'id' => 'r-036',
'kind' => 'external_data',
'title' => 'Kitchen and supplies restock schedule',
'source' => 'internal-ops',
'text' => 'Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.'
]
],
'task' => [
'prompt' => 'What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?',
'tool_name' => 'resolve_billing_dispute'
],
'budget' => [
'max_context_tokens' => 900,
'operating_point' => 'np-2026-08-r4'
],
'render' => true,
'render_format' => 'plain',
'return_per_record' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nextmoca.com/v1/context/select"
payload := strings.NewReader("{\n \"request_id\": \"req-2026-09-03-0001\",\n \"records\": [\n {\n \"id\": \"r-001\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(88231)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 88231, \\\"account\\\": \\\"acct_4415\\\", \\\"total_cents\\\": 432000, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"open\\\", \\\"issued\\\": \\\"2026-07-28\\\", \\\"due\\\": \\\"2026-08-27\\\", \\\"line_items\\\": [{\\\"sku\\\": \\\"NP-USAGE\\\", \\\"desc\\\": \\\"Metered input tokens, July\\\", \\\"qty\\\": 4800000, \\\"unit_price_cents\\\": 0.009}, {\\\"sku\\\": \\\"NP-SUPPORT\\\", \\\"desc\\\": \\\"Priority support\\\", \\\"qty\\\": 1, \\\"unit_price_cents\\\": 49900}]}\"\n },\n {\n \"id\": \"r-002\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_4415)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"name\\\": \\\"Meridian Analytics\\\", \\\"plan\\\": \\\"scale\\\", \\\"payment_method\\\": \\\"card_visa_6411\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2025-11-03\\\", \\\"owner\\\": \\\"dana@meridiananalytics.com\\\"}\"\n },\n {\n \"id\": \"r-003\",\n \"kind\": \"external_data\",\n \"title\": \"Data retention policy v3\",\n \"source\": \"handbook\",\n \"text\": \"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.\"\n },\n {\n \"id\": \"r-004\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 2\",\n \"source\": \"handbook\",\n \"text\": \"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\"\n },\n {\n \"id\": \"r-005\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 3 (exceptions)\",\n \"source\": \"handbook\",\n \"text\": \"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\"\n },\n {\n \"id\": \"r-006\",\n \"kind\": \"tool_result\",\n \"title\": \"get_usage(acct_4415, july)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"period\\\": \\\"2026-07\\\", \\\"input_tokens\\\": 4800000, \\\"requests\\\": 1210, \\\"stand_downs\\\": 34, \\\"charged_tokens\\\": 4646000}\"\n },\n {\n \"id\": \"r-007\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_9902)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5488\\\", \\\"subject\\\": \\\"API key rotation question\\\", \\\"opened\\\": \\\"2026-08-02\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-008\",\n \"kind\": \"user_input\",\n \"title\": null,\n \"source\": null,\n \"text\": \"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\"\n },\n {\n \"id\": \"r-009\",\n \"kind\": \"external_data\",\n \"title\": \"Credit policy v2\",\n \"source\": \"handbook\",\n \"text\": \"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.\"\n },\n {\n \"id\": \"r-012\",\n \"kind\": \"tool_result\",\n \"title\": \"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"keys\\\": [{\\\"key_id\\\": \\\"np_key_a1\\\", \\\"requests\\\": 980, \\\"user_agent\\\": \\\"meridian-batch/2.1\\\", \\\"tokens\\\": 3100000}, {\\\"key_id\\\": \\\"np_key_b2\\\", \\\"requests\\\": 230, \\\"user_agent\\\": \\\"meridian-app/1.4\\\", \\\"tokens\\\": 1700000}], \\\"note\\\": \\\"np_key_a1 traffic stops 2026-07-19T14:02Z\\\"}\"\n },\n {\n \"id\": \"r-013\",\n \"kind\": \"external_data\",\n \"title\": \"Q2 headcount planning notes\",\n \"source\": \"internal-ops\",\n \"text\": \"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.\"\n },\n {\n \"id\": \"r-014\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(55102)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 55102, \\\"account\\\": \\\"acct_2210\\\", \\\"total_cents\\\": 18900, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"paid\\\", \\\"issued\\\": \\\"2026-07-15\\\", \\\"due\\\": \\\"2026-08-14\\\"}\"\n },\n {\n \"id\": \"r-015\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 marketing newsletter draft\",\n \"source\": \"marketing\",\n \"text\": \"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.\"\n },\n {\n \"id\": \"r-016\",\n \"kind\": \"external_data\",\n \"title\": \"Office move logistics\",\n \"source\": \"internal-ops\",\n \"text\": \"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.\"\n },\n {\n \"id\": \"r-017\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_4415)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5521\\\", \\\"subject\\\": \\\"July usage dispute\\\", \\\"opened\\\": \\\"2026-08-05\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-2\\\"}]}\"\n },\n {\n \"id\": \"r-018\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_2210)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5502\\\", \\\"subject\\\": \\\"Login issue after SSO migration\\\", \\\"opened\\\": \\\"2026-08-01\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-019\",\n \"kind\": \"external_data\",\n \"title\": \"Vacation and PTO policy\",\n \"source\": \"handbook\",\n \"text\": \"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.\"\n },\n {\n \"id\": \"r-020\",\n \"kind\": \"external_data\",\n \"title\": \"Runbook: rotating a compromised API key\",\n \"source\": \"ops-wiki\",\n \"text\": \"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.\"\n },\n {\n \"id\": \"r-021\",\n \"kind\": \"llm_response\",\n \"text\": \"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.\"\n },\n {\n \"id\": \"r-022\",\n \"kind\": \"external_data\",\n \"title\": \"Customer advisory board Q4 invite draft\",\n \"source\": \"marketing\",\n \"text\": \"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.\"\n },\n {\n \"id\": \"r-023\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_9902)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_9902\\\", \\\"name\\\": \\\"Colby Fixtures\\\", \\\"plan\\\": \\\"growth\\\", \\\"payment_method\\\": \\\"card_mc_2290\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2026-01-14\\\", \\\"owner\\\": \\\"ops@colbyfixtures.com\\\"}\"\n },\n {\n \"id\": \"r-026\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_5511)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5510\\\", \\\"subject\\\": \\\"Feature request: CSV export for usage analytics\\\", \\\"opened\\\": \\\"2026-08-03\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-027\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 all-hands agenda\",\n \"source\": \"internal-ops\",\n \"text\": \"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.\"\n },\n {\n \"id\": \"r-029\",\n \"kind\": \"external_data\",\n \"title\": \"Marketing site refresh, visual only\",\n \"source\": \"marketing\",\n \"text\": \"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.\"\n },\n {\n \"id\": \"r-031\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_6630)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5477\\\", \\\"subject\\\": \\\"Onboarding walkthrough request\\\", \\\"opened\\\": \\\"2026-07-30\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-032\",\n \"kind\": \"external_data\",\n \"title\": \"On-call rotation for September\",\n \"source\": \"internal-ops\",\n \"text\": \"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.\"\n },\n {\n \"id\": \"r-033\",\n \"kind\": \"external_data\",\n \"title\": \"Partner co-marketing webinar recap\",\n \"source\": \"marketing\",\n \"text\": \"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.\"\n },\n {\n \"id\": \"r-034\",\n \"kind\": \"external_data\",\n \"title\": \"Conference room booking policy\",\n \"source\": \"handbook\",\n \"text\": \"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.\"\n },\n {\n \"id\": \"r-035\",\n \"kind\": \"external_data\",\n \"title\": \"Blog editorial calendar, Q4\",\n \"source\": \"marketing\",\n \"text\": \"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.\"\n },\n {\n \"id\": \"r-036\",\n \"kind\": \"external_data\",\n \"title\": \"Kitchen and supplies restock schedule\",\n \"source\": \"internal-ops\",\n \"text\": \"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.\"\n }\n ],\n \"task\": {\n \"prompt\": \"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?\",\n \"tool_name\": \"resolve_billing_dispute\"\n },\n \"budget\": {\n \"max_context_tokens\": 900,\n \"operating_point\": \"np-2026-08-r4\"\n },\n \"render\": true,\n \"render_format\": \"plain\",\n \"return_per_record\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://api.nextmoca.com/v1/context/select")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"request_id\": \"req-2026-09-03-0001\",\n \"records\": [\n {\n \"id\": \"r-001\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(88231)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 88231, \\\"account\\\": \\\"acct_4415\\\", \\\"total_cents\\\": 432000, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"open\\\", \\\"issued\\\": \\\"2026-07-28\\\", \\\"due\\\": \\\"2026-08-27\\\", \\\"line_items\\\": [{\\\"sku\\\": \\\"NP-USAGE\\\", \\\"desc\\\": \\\"Metered input tokens, July\\\", \\\"qty\\\": 4800000, \\\"unit_price_cents\\\": 0.009}, {\\\"sku\\\": \\\"NP-SUPPORT\\\", \\\"desc\\\": \\\"Priority support\\\", \\\"qty\\\": 1, \\\"unit_price_cents\\\": 49900}]}\"\n },\n {\n \"id\": \"r-002\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_4415)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"name\\\": \\\"Meridian Analytics\\\", \\\"plan\\\": \\\"scale\\\", \\\"payment_method\\\": \\\"card_visa_6411\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2025-11-03\\\", \\\"owner\\\": \\\"dana@meridiananalytics.com\\\"}\"\n },\n {\n \"id\": \"r-003\",\n \"kind\": \"external_data\",\n \"title\": \"Data retention policy v3\",\n \"source\": \"handbook\",\n \"text\": \"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.\"\n },\n {\n \"id\": \"r-004\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 2\",\n \"source\": \"handbook\",\n \"text\": \"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\"\n },\n {\n \"id\": \"r-005\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 3 (exceptions)\",\n \"source\": \"handbook\",\n \"text\": \"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\"\n },\n {\n \"id\": \"r-006\",\n \"kind\": \"tool_result\",\n \"title\": \"get_usage(acct_4415, july)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"period\\\": \\\"2026-07\\\", \\\"input_tokens\\\": 4800000, \\\"requests\\\": 1210, \\\"stand_downs\\\": 34, \\\"charged_tokens\\\": 4646000}\"\n },\n {\n \"id\": \"r-007\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_9902)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5488\\\", \\\"subject\\\": \\\"API key rotation question\\\", \\\"opened\\\": \\\"2026-08-02\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-008\",\n \"kind\": \"user_input\",\n \"title\": null,\n \"source\": null,\n \"text\": \"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\"\n },\n {\n \"id\": \"r-009\",\n \"kind\": \"external_data\",\n \"title\": \"Credit policy v2\",\n \"source\": \"handbook\",\n \"text\": \"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.\"\n },\n {\n \"id\": \"r-012\",\n \"kind\": \"tool_result\",\n \"title\": \"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"keys\\\": [{\\\"key_id\\\": \\\"np_key_a1\\\", \\\"requests\\\": 980, \\\"user_agent\\\": \\\"meridian-batch/2.1\\\", \\\"tokens\\\": 3100000}, {\\\"key_id\\\": \\\"np_key_b2\\\", \\\"requests\\\": 230, \\\"user_agent\\\": \\\"meridian-app/1.4\\\", \\\"tokens\\\": 1700000}], \\\"note\\\": \\\"np_key_a1 traffic stops 2026-07-19T14:02Z\\\"}\"\n },\n {\n \"id\": \"r-013\",\n \"kind\": \"external_data\",\n \"title\": \"Q2 headcount planning notes\",\n \"source\": \"internal-ops\",\n \"text\": \"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.\"\n },\n {\n \"id\": \"r-014\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(55102)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 55102, \\\"account\\\": \\\"acct_2210\\\", \\\"total_cents\\\": 18900, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"paid\\\", \\\"issued\\\": \\\"2026-07-15\\\", \\\"due\\\": \\\"2026-08-14\\\"}\"\n },\n {\n \"id\": \"r-015\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 marketing newsletter draft\",\n \"source\": \"marketing\",\n \"text\": \"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.\"\n },\n {\n \"id\": \"r-016\",\n \"kind\": \"external_data\",\n \"title\": \"Office move logistics\",\n \"source\": \"internal-ops\",\n \"text\": \"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.\"\n },\n {\n \"id\": \"r-017\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_4415)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5521\\\", \\\"subject\\\": \\\"July usage dispute\\\", \\\"opened\\\": \\\"2026-08-05\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-2\\\"}]}\"\n },\n {\n \"id\": \"r-018\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_2210)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5502\\\", \\\"subject\\\": \\\"Login issue after SSO migration\\\", \\\"opened\\\": \\\"2026-08-01\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-019\",\n \"kind\": \"external_data\",\n \"title\": \"Vacation and PTO policy\",\n \"source\": \"handbook\",\n \"text\": \"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.\"\n },\n {\n \"id\": \"r-020\",\n \"kind\": \"external_data\",\n \"title\": \"Runbook: rotating a compromised API key\",\n \"source\": \"ops-wiki\",\n \"text\": \"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.\"\n },\n {\n \"id\": \"r-021\",\n \"kind\": \"llm_response\",\n \"text\": \"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.\"\n },\n {\n \"id\": \"r-022\",\n \"kind\": \"external_data\",\n \"title\": \"Customer advisory board Q4 invite draft\",\n \"source\": \"marketing\",\n \"text\": \"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.\"\n },\n {\n \"id\": \"r-023\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_9902)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_9902\\\", \\\"name\\\": \\\"Colby Fixtures\\\", \\\"plan\\\": \\\"growth\\\", \\\"payment_method\\\": \\\"card_mc_2290\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2026-01-14\\\", \\\"owner\\\": \\\"ops@colbyfixtures.com\\\"}\"\n },\n {\n \"id\": \"r-026\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_5511)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5510\\\", \\\"subject\\\": \\\"Feature request: CSV export for usage analytics\\\", \\\"opened\\\": \\\"2026-08-03\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-027\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 all-hands agenda\",\n \"source\": \"internal-ops\",\n \"text\": \"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.\"\n },\n {\n \"id\": \"r-029\",\n \"kind\": \"external_data\",\n \"title\": \"Marketing site refresh, visual only\",\n \"source\": \"marketing\",\n \"text\": \"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.\"\n },\n {\n \"id\": \"r-031\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_6630)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5477\\\", \\\"subject\\\": \\\"Onboarding walkthrough request\\\", \\\"opened\\\": \\\"2026-07-30\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-032\",\n \"kind\": \"external_data\",\n \"title\": \"On-call rotation for September\",\n \"source\": \"internal-ops\",\n \"text\": \"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.\"\n },\n {\n \"id\": \"r-033\",\n \"kind\": \"external_data\",\n \"title\": \"Partner co-marketing webinar recap\",\n \"source\": \"marketing\",\n \"text\": \"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.\"\n },\n {\n \"id\": \"r-034\",\n \"kind\": \"external_data\",\n \"title\": \"Conference room booking policy\",\n \"source\": \"handbook\",\n \"text\": \"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.\"\n },\n {\n \"id\": \"r-035\",\n \"kind\": \"external_data\",\n \"title\": \"Blog editorial calendar, Q4\",\n \"source\": \"marketing\",\n \"text\": \"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.\"\n },\n {\n \"id\": \"r-036\",\n \"kind\": \"external_data\",\n \"title\": \"Kitchen and supplies restock schedule\",\n \"source\": \"internal-ops\",\n \"text\": \"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.\"\n }\n ],\n \"task\": {\n \"prompt\": \"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?\",\n \"tool_name\": \"resolve_billing_dispute\"\n },\n \"budget\": {\n \"max_context_tokens\": 900,\n \"operating_point\": \"np-2026-08-r4\"\n },\n \"render\": true,\n \"render_format\": \"plain\",\n \"return_per_record\": true\n}")
.asString();
require 'uri'
require 'net/http'
url = URI("https://api.nextmoca.com/v1/context/select")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"request_id\": \"req-2026-09-03-0001\",\n \"records\": [\n {\n \"id\": \"r-001\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(88231)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 88231, \\\"account\\\": \\\"acct_4415\\\", \\\"total_cents\\\": 432000, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"open\\\", \\\"issued\\\": \\\"2026-07-28\\\", \\\"due\\\": \\\"2026-08-27\\\", \\\"line_items\\\": [{\\\"sku\\\": \\\"NP-USAGE\\\", \\\"desc\\\": \\\"Metered input tokens, July\\\", \\\"qty\\\": 4800000, \\\"unit_price_cents\\\": 0.009}, {\\\"sku\\\": \\\"NP-SUPPORT\\\", \\\"desc\\\": \\\"Priority support\\\", \\\"qty\\\": 1, \\\"unit_price_cents\\\": 49900}]}\"\n },\n {\n \"id\": \"r-002\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_4415)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"name\\\": \\\"Meridian Analytics\\\", \\\"plan\\\": \\\"scale\\\", \\\"payment_method\\\": \\\"card_visa_6411\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2025-11-03\\\", \\\"owner\\\": \\\"dana@meridiananalytics.com\\\"}\"\n },\n {\n \"id\": \"r-003\",\n \"kind\": \"external_data\",\n \"title\": \"Data retention policy v3\",\n \"source\": \"handbook\",\n \"text\": \"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.\"\n },\n {\n \"id\": \"r-004\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 2\",\n \"source\": \"handbook\",\n \"text\": \"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\"\n },\n {\n \"id\": \"r-005\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 3 (exceptions)\",\n \"source\": \"handbook\",\n \"text\": \"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\"\n },\n {\n \"id\": \"r-006\",\n \"kind\": \"tool_result\",\n \"title\": \"get_usage(acct_4415, july)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"period\\\": \\\"2026-07\\\", \\\"input_tokens\\\": 4800000, \\\"requests\\\": 1210, \\\"stand_downs\\\": 34, \\\"charged_tokens\\\": 4646000}\"\n },\n {\n \"id\": \"r-007\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_9902)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5488\\\", \\\"subject\\\": \\\"API key rotation question\\\", \\\"opened\\\": \\\"2026-08-02\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-008\",\n \"kind\": \"user_input\",\n \"title\": null,\n \"source\": null,\n \"text\": \"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\"\n },\n {\n \"id\": \"r-009\",\n \"kind\": \"external_data\",\n \"title\": \"Credit policy v2\",\n \"source\": \"handbook\",\n \"text\": \"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.\"\n },\n {\n \"id\": \"r-012\",\n \"kind\": \"tool_result\",\n \"title\": \"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"keys\\\": [{\\\"key_id\\\": \\\"np_key_a1\\\", \\\"requests\\\": 980, \\\"user_agent\\\": \\\"meridian-batch/2.1\\\", \\\"tokens\\\": 3100000}, {\\\"key_id\\\": \\\"np_key_b2\\\", \\\"requests\\\": 230, \\\"user_agent\\\": \\\"meridian-app/1.4\\\", \\\"tokens\\\": 1700000}], \\\"note\\\": \\\"np_key_a1 traffic stops 2026-07-19T14:02Z\\\"}\"\n },\n {\n \"id\": \"r-013\",\n \"kind\": \"external_data\",\n \"title\": \"Q2 headcount planning notes\",\n \"source\": \"internal-ops\",\n \"text\": \"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.\"\n },\n {\n \"id\": \"r-014\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(55102)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 55102, \\\"account\\\": \\\"acct_2210\\\", \\\"total_cents\\\": 18900, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"paid\\\", \\\"issued\\\": \\\"2026-07-15\\\", \\\"due\\\": \\\"2026-08-14\\\"}\"\n },\n {\n \"id\": \"r-015\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 marketing newsletter draft\",\n \"source\": \"marketing\",\n \"text\": \"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.\"\n },\n {\n \"id\": \"r-016\",\n \"kind\": \"external_data\",\n \"title\": \"Office move logistics\",\n \"source\": \"internal-ops\",\n \"text\": \"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.\"\n },\n {\n \"id\": \"r-017\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_4415)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5521\\\", \\\"subject\\\": \\\"July usage dispute\\\", \\\"opened\\\": \\\"2026-08-05\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-2\\\"}]}\"\n },\n {\n \"id\": \"r-018\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_2210)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5502\\\", \\\"subject\\\": \\\"Login issue after SSO migration\\\", \\\"opened\\\": \\\"2026-08-01\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-019\",\n \"kind\": \"external_data\",\n \"title\": \"Vacation and PTO policy\",\n \"source\": \"handbook\",\n \"text\": \"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.\"\n },\n {\n \"id\": \"r-020\",\n \"kind\": \"external_data\",\n \"title\": \"Runbook: rotating a compromised API key\",\n \"source\": \"ops-wiki\",\n \"text\": \"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.\"\n },\n {\n \"id\": \"r-021\",\n \"kind\": \"llm_response\",\n \"text\": \"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.\"\n },\n {\n \"id\": \"r-022\",\n \"kind\": \"external_data\",\n \"title\": \"Customer advisory board Q4 invite draft\",\n \"source\": \"marketing\",\n \"text\": \"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.\"\n },\n {\n \"id\": \"r-023\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_9902)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_9902\\\", \\\"name\\\": \\\"Colby Fixtures\\\", \\\"plan\\\": \\\"growth\\\", \\\"payment_method\\\": \\\"card_mc_2290\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2026-01-14\\\", \\\"owner\\\": \\\"ops@colbyfixtures.com\\\"}\"\n },\n {\n \"id\": \"r-026\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_5511)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5510\\\", \\\"subject\\\": \\\"Feature request: CSV export for usage analytics\\\", \\\"opened\\\": \\\"2026-08-03\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-027\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 all-hands agenda\",\n \"source\": \"internal-ops\",\n \"text\": \"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.\"\n },\n {\n \"id\": \"r-029\",\n \"kind\": \"external_data\",\n \"title\": \"Marketing site refresh, visual only\",\n \"source\": \"marketing\",\n \"text\": \"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.\"\n },\n {\n \"id\": \"r-031\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_6630)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5477\\\", \\\"subject\\\": \\\"Onboarding walkthrough request\\\", \\\"opened\\\": \\\"2026-07-30\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-032\",\n \"kind\": \"external_data\",\n \"title\": \"On-call rotation for September\",\n \"source\": \"internal-ops\",\n \"text\": \"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.\"\n },\n {\n \"id\": \"r-033\",\n \"kind\": \"external_data\",\n \"title\": \"Partner co-marketing webinar recap\",\n \"source\": \"marketing\",\n \"text\": \"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.\"\n },\n {\n \"id\": \"r-034\",\n \"kind\": \"external_data\",\n \"title\": \"Conference room booking policy\",\n \"source\": \"handbook\",\n \"text\": \"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.\"\n },\n {\n \"id\": \"r-035\",\n \"kind\": \"external_data\",\n \"title\": \"Blog editorial calendar, Q4\",\n \"source\": \"marketing\",\n \"text\": \"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.\"\n },\n {\n \"id\": \"r-036\",\n \"kind\": \"external_data\",\n \"title\": \"Kitchen and supplies restock schedule\",\n \"source\": \"internal-ops\",\n \"text\": \"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.\"\n }\n ],\n \"task\": {\n \"prompt\": \"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?\",\n \"tool_name\": \"resolve_billing_dispute\"\n },\n \"budget\": {\n \"max_context_tokens\": 900,\n \"operating_point\": \"np-2026-08-r4\"\n },\n \"render\": true,\n \"render_format\": \"plain\",\n \"return_per_record\": true\n}"
response = http.request(request)
puts response.read_body
{ "request_id": "req-2026-09-03-0001", "rendered_context": "Relevant State\n\n1. Credit policy v2 (handbook)\nService credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method.\nCredits require the account owner's written acknowledgement of the cause.\n\n2. user_input\nCustomer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\n\n3. Refund policy v4, section 3 (exceptions) (handbook)\nException: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\n\n4. Refund policy v4, section 2 (handbook)\nRefunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\n\n5. llm_response\nI've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.", "policy_version": "np-2026-08-r4", "selected": [ { "record_id": "r-009", "kind": "external_data", "title": "Credit policy v2", "source": "handbook", "score": 32.658829095499584, "reason": "hard context: answer-bearing evidence: keyword overlap", "excerpt": "Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method.\nCredits require the account owner's written acknowledgement of the cause.", "excerpt_format": "plain", "selected_tokens": 76 }, { "record_id": "r-008", "kind": "user_input", "title": null, "source": null, "score": 54.106697605930485, "reason": "hard context: weighted evidence coverage: current request; keyword overlap; semantic tag overlap", "excerpt": "Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?", "excerpt_format": "plain", "selected_tokens": 60 }, { "record_id": "r-005", "kind": "external_data", "title": "Refund policy v4, section 3 (exceptions)", "source": "handbook", "score": 13.458636537340059, "reason": "hard context: weighted evidence coverage: keyword overlap", "excerpt": "Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.", "excerpt_format": "plain", "selected_tokens": 67 }, { "record_id": "r-004", "kind": "external_data", "title": "Refund policy v4, section 2", "source": "handbook", "score": 14.01558939758398, "reason": "hard context: recent relevant result: keyword overlap", "excerpt": "Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.", "excerpt_format": "plain", "selected_tokens": 74 }, { "record_id": "r-021", "kind": "llm_response", "title": null, "source": null, "score": 14.644259731672935, "reason": "soft context: keyword overlap", "excerpt": "I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.", "excerpt_format": "plain", "selected_tokens": 37 } ], "tokens_before": 1775, "tokens_after": 314, "tokens_saved": 1461, "records_available": 30, "records_selected": 5, "fallback_used": false, "selection_error": null, "engine_latency_ms": 7.534137000220653, "budget_tokens": 900, "attempted_budget_tokens": [ 900 ], "reduction_ratio": 0.8230985915492958, "safety": { "selection_safe": true, "fallback_required": false, "fallback_reason": "", "coverage_score": 1, "evidence_shape": "exact_anchor_lookup", "evidence_terms": null, "repair_reasons": [] }, "gate": { "engaged": true, "reason": "engage:delivered_support_complete", "signals": { "n_candidates": 21, "high_drift": false } }, "format_metrics": { "context_format": "plain", "formatted_context_tokens": 361, "plain_context_tokens": 361, "toon_context_tokens": null, "toon_applied": false, "whole_context_toon_applied": false, "structured_toon_excerpts": 0, "structured_toon_tokens_saved": 0, "toon_tokens_saved_vs_plain": 0, "selection_strategy_used": "fast", "selection_strategy_initial": "fast", "support_contract_used": "generic", "adapter_attempt_count": 1, "semantic_adapter_ids": [ "generic" ], "semantic_routing_bounds_hit": false, "semantic_adapter_registry_version": "np-adapters-2026-08-r1", "semantic_router_version": "np-router-2026-08-r3", "semantic_normalizer_version": "np-normalizer-2026-08-r1", "support_contract_resolution_version": "np-support-resolution-2026-08-r3", "attempted_recall_rungs": [ { "candidate_limit": 250, "min_selection_score": 8, "max_selected_records": 18, "max_selected_tokens": 900 } ] }, "selection_strategy_used": "fast", "support_contract_used": "generic", "adapter_attempt_count": 1, "usage": { "meter_version": "npm-2026-08-r1", "outcome": "engaged", "input_tokens": 1998, "charge_multiplier": "1.0", "price_version": "npp-2026-10-r1", "currency": "USD" }, "outcome": "engaged", "records_submitted": 30, "records_admitted": 30, "candidates_truncated": false, "selection_recall": { "version": "npsr-2026-08-r2", "operating_point": "np-2026-08-r4", "records_submitted": 30, "records_admitted": 30, "candidate_matches_total": 21, "candidates_scored": 21, "candidates_above_floor": 5, "records_selected": 5, "candidate_limit_hit": false, "weighted_term_coverage": 0.4838709677419355, "excerpt_term_coverage": 0.44086021505376344, "rejection_counts": { "hard_entity_conflict": 0, "secret_payload": 0, "below_selection_floor": 16, "record_count_budget": 0, "token_budget": 0, "excerpt_coverage_loss": 0 }, "evidence_confidence_score": 1, "lexical_coverage": 0.44086021505376344 }, "task_kind": "pointed"}
Selection
Select the records worth sending to a model
Send every record you are considering plus the task they must serve.
Needlepath returns the subset it selected, together with a rendered
block, per-record scores and reasons, and the token arithmetic.
Selection, not rewriting. Nothing is paraphrased or summarised into
new prose and no model writes replacement text; an excerpt is built from
the record’s own content. It is not guaranteed byte-identical to a
span of your input. See SelectedRecord.excerpt. If you need exact
spans, join on record_id and use your own copy.
Stateless. Records ride in on every request and nothing is persisted
between calls, unless you have asked us in writing to capture your own
requests for a review (see Retention and trust). The same request under the same operating_point gets
the same answer, with two caveats before you assert on it in a test:
that guarantee is scoped to the request exactly as sent, so record order
is part of it, and a record sent without an id comes back under a
freshly generated one. Send ids, and send a stable order.
A stand-down is a success. When Needlepath cannot find evidence that a
smaller context covers the task, it stands down and returns your context
essentially intact with fallback_used = true: on np-2026-07-r2 as
outcome = stood_down with an empty selection, and on np-2026-08-r3,
np-2026-08-r4, np-2026-10-r6, np-2026-10-r7 and np-2026-10-r8 as outcome = engaged with every record
returned. Treat it as a normal 200 and send what you were going to send, and
do not treat a low tokens_saved as an error. Read outcome for this, never
gate.
Fail open. If this call times out, returns non-2xx, or returns an
empty selection, send your original context unmodified. It is a binding
rule for every integration, first-party or yours.
POST
/
v1
/
context
/
select
cURL
curl https://api.nextmoca.com/v1/context/select \ -H "Authorization: Bearer $NEEDLEPATH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "request_id": "req-2026-09-03-0001", "records": [ { "id": "r-001", "kind": "tool_result", "title": "get_invoice(88231)", "source": "billing-api", "text": "{\"invoice_id\": 88231, \"account\": \"acct_4415\", \"total_cents\": 432000, \"currency\": \"usd\", \"status\": \"open\", \"issued\": \"2026-07-28\", \"due\": \"2026-08-27\", \"line_items\": [{\"sku\": \"NP-USAGE\", \"desc\": \"Metered input tokens, July\", \"qty\": 4800000, \"unit_price_cents\": 0.009}, {\"sku\": \"NP-SUPPORT\", \"desc\": \"Priority support\", \"qty\": 1, \"unit_price_cents\": 49900}]}" }, { "id": "r-002", "kind": "tool_result", "title": "get_account(acct_4415)", "source": "crm-api", "text": "{\"account_id\": \"acct_4415\", \"name\": \"Meridian Analytics\", \"plan\": \"scale\", \"payment_method\": \"card_visa_6411\", \"delinquent\": false, \"since\": \"2025-11-03\", \"owner\": \"dana@meridiananalytics.com\"}" }, { "id": "r-003", "kind": "external_data", "title": "Data retention policy v3", "source": "handbook", "text": "Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility." }, { "id": "r-004", "kind": "external_data", "title": "Refund policy v4, section 2", "source": "handbook", "text": "Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible." }, { "id": "r-005", "kind": "external_data", "title": "Refund policy v4, section 3 (exceptions)", "source": "handbook", "text": "Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead'\''s discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered." }, { "id": "r-006", "kind": "tool_result", "title": "get_usage(acct_4415, july)", "source": "metering-api", "text": "{\"account_id\": \"acct_4415\", \"period\": \"2026-07\", \"input_tokens\": 4800000, \"requests\": 1210, \"stand_downs\": 34, \"charged_tokens\": 4646000}" }, { "id": "r-007", "kind": "tool_result", "title": "get_open_tickets(acct_9902)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5488\", \"subject\": \"API key rotation question\", \"opened\": \"2026-08-02\", \"status\": \"closed\", \"assignee\": \"support-lead-1\"}]}" }, { "id": "r-008", "kind": "user_input", "title": null, "source": null, "text": "Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?" }, { "id": "r-009", "kind": "external_data", "title": "Credit policy v2", "source": "handbook", "text": "Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner'\''s written acknowledgement of the cause." }, { "id": "r-012", "kind": "tool_result", "title": "get_key_traffic(acct_4415, 2026-07-01..2026-07-19)", "source": "metering-api", "text": "{\"keys\": [{\"key_id\": \"np_key_a1\", \"requests\": 980, \"user_agent\": \"meridian-batch/2.1\", \"tokens\": 3100000}, {\"key_id\": \"np_key_b2\", \"requests\": 230, \"user_agent\": \"meridian-app/1.4\", \"tokens\": 1700000}], \"note\": \"np_key_a1 traffic stops 2026-07-19T14:02Z\"}" }, { "id": "r-013", "kind": "external_data", "title": "Q2 headcount planning notes", "source": "internal-ops", "text": "The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3." }, { "id": "r-014", "kind": "tool_result", "title": "get_invoice(55102)", "source": "billing-api", "text": "{\"invoice_id\": 55102, \"account\": \"acct_2210\", \"total_cents\": 18900, \"currency\": \"usd\", \"status\": \"paid\", \"issued\": \"2026-07-15\", \"due\": \"2026-08-14\"}" }, { "id": "r-015", "kind": "external_data", "title": "Q3 marketing newsletter draft", "source": "marketing", "text": "Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September." }, { "id": "r-016", "kind": "external_data", "title": "Office move logistics", "source": "internal-ops", "text": "The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes." }, { "id": "r-017", "kind": "tool_result", "title": "get_open_tickets(acct_4415)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5521\", \"subject\": \"July usage dispute\", \"opened\": \"2026-08-05\", \"status\": \"open\", \"assignee\": \"support-lead-2\"}]}" }, { "id": "r-018", "kind": "tool_result", "title": "get_open_tickets(acct_2210)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5502\", \"subject\": \"Login issue after SSO migration\", \"opened\": \"2026-08-01\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}" }, { "id": "r-019", "kind": "external_data", "title": "Vacation and PTO policy", "source": "handbook", "text": "Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect." }, { "id": "r-020", "kind": "external_data", "title": "Runbook: rotating a compromised API key", "source": "ops-wiki", "text": "If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes." }, { "id": "r-021", "kind": "llm_response", "text": "I'\''ve pulled up account acct_4415 and I'\''m reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown." }, { "id": "r-022", "kind": "external_data", "title": "Customer advisory board Q4 invite draft", "source": "marketing", "text": "Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support." }, { "id": "r-023", "kind": "tool_result", "title": "get_account(acct_9902)", "source": "crm-api", "text": "{\"account_id\": \"acct_9902\", \"name\": \"Colby Fixtures\", \"plan\": \"growth\", \"payment_method\": \"card_mc_2290\", \"delinquent\": false, \"since\": \"2026-01-14\", \"owner\": \"ops@colbyfixtures.com\"}" }, { "id": "r-026", "kind": "tool_result", "title": "get_open_tickets(acct_5511)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5510\", \"subject\": \"Feature request: CSV export for usage analytics\", \"opened\": \"2026-08-03\", \"status\": \"open\", \"assignee\": \"support-lead-1\"}]}" }, { "id": "r-027", "kind": "external_data", "title": "Q3 all-hands agenda", "source": "internal-ops", "text": "Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live." }, { "id": "r-029", "kind": "external_data", "title": "Marketing site refresh, visual only", "source": "marketing", "text": "The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only." }, { "id": "r-031", "kind": "tool_result", "title": "get_open_tickets(acct_6630)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5477\", \"subject\": \"Onboarding walkthrough request\", \"opened\": \"2026-07-30\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}" }, { "id": "r-032", "kind": "external_data", "title": "On-call rotation for September", "source": "internal-ops", "text": "September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead." }, { "id": "r-033", "kind": "external_data", "title": "Partner co-marketing webinar recap", "source": "marketing", "text": "Tuesday'\''s co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week." }, { "id": "r-034", "kind": "external_data", "title": "Conference room booking policy", "source": "handbook", "text": "Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing." }, { "id": "r-035", "kind": "external_data", "title": "Blog editorial calendar, Q4", "source": "marketing", "text": "Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication." }, { "id": "r-036", "kind": "external_data", "title": "Kitchen and supplies restock schedule", "source": "internal-ops", "text": "Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week." } ], "task": { "prompt": "What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?", "tool_name": "resolve_billing_dispute" }, "budget": { "max_context_tokens": 900, "operating_point": "np-2026-08-r4" }, "render": true, "render_format": "plain", "return_per_record": true}'
import os
import requests
payload = {
"request_id": "req-2026-09-03-0001",
"records": [
{
"id": "r-001",
"kind": "tool_result",
"title": "get_invoice(88231)",
"source": "billing-api",
"text": "{\"invoice_id\": 88231, \"account\": \"acct_4415\", \"total_cents\": 432000, \"currency\": \"usd\", \"status\": \"open\", \"issued\": \"2026-07-28\", \"due\": \"2026-08-27\", \"line_items\": [{\"sku\": \"NP-USAGE\", \"desc\": \"Metered input tokens, July\", \"qty\": 4800000, \"unit_price_cents\": 0.009}, {\"sku\": \"NP-SUPPORT\", \"desc\": \"Priority support\", \"qty\": 1, \"unit_price_cents\": 49900}]}",
},
{
"id": "r-002",
"kind": "tool_result",
"title": "get_account(acct_4415)",
"source": "crm-api",
"text": "{\"account_id\": \"acct_4415\", \"name\": \"Meridian Analytics\", \"plan\": \"scale\", \"payment_method\": \"card_visa_6411\", \"delinquent\": false, \"since\": \"2025-11-03\", \"owner\": \"dana@meridiananalytics.com\"}",
},
{
"id": "r-003",
"kind": "external_data",
"title": "Data retention policy v3",
"source": "handbook",
"text": "Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.",
},
{
"id": "r-004",
"kind": "external_data",
"title": "Refund policy v4, section 2",
"source": "handbook",
"text": "Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.",
},
{
"id": "r-005",
"kind": "external_data",
"title": "Refund policy v4, section 3 (exceptions)",
"source": "handbook",
"text": "Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.",
},
{
"id": "r-006",
"kind": "tool_result",
"title": "get_usage(acct_4415, july)",
"source": "metering-api",
"text": "{\"account_id\": \"acct_4415\", \"period\": \"2026-07\", \"input_tokens\": 4800000, \"requests\": 1210, \"stand_downs\": 34, \"charged_tokens\": 4646000}",
},
{
"id": "r-007",
"kind": "tool_result",
"title": "get_open_tickets(acct_9902)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5488\", \"subject\": \"API key rotation question\", \"opened\": \"2026-08-02\", \"status\": \"closed\", \"assignee\": \"support-lead-1\"}]}",
},
{
"id": "r-008",
"kind": "user_input",
"title": None,
"source": None,
"text": "Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?",
},
{
"id": "r-009",
"kind": "external_data",
"title": "Credit policy v2",
"source": "handbook",
"text": "Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.",
},
{
"id": "r-012",
"kind": "tool_result",
"title": "get_key_traffic(acct_4415, 2026-07-01..2026-07-19)",
"source": "metering-api",
"text": "{\"keys\": [{\"key_id\": \"np_key_a1\", \"requests\": 980, \"user_agent\": \"meridian-batch/2.1\", \"tokens\": 3100000}, {\"key_id\": \"np_key_b2\", \"requests\": 230, \"user_agent\": \"meridian-app/1.4\", \"tokens\": 1700000}], \"note\": \"np_key_a1 traffic stops 2026-07-19T14:02Z\"}",
},
{
"id": "r-013",
"kind": "external_data",
"title": "Q2 headcount planning notes",
"source": "internal-ops",
"text": "The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.",
},
{
"id": "r-014",
"kind": "tool_result",
"title": "get_invoice(55102)",
"source": "billing-api",
"text": "{\"invoice_id\": 55102, \"account\": \"acct_2210\", \"total_cents\": 18900, \"currency\": \"usd\", \"status\": \"paid\", \"issued\": \"2026-07-15\", \"due\": \"2026-08-14\"}",
},
{
"id": "r-015",
"kind": "external_data",
"title": "Q3 marketing newsletter draft",
"source": "marketing",
"text": "Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.",
},
{
"id": "r-016",
"kind": "external_data",
"title": "Office move logistics",
"source": "internal-ops",
"text": "The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.",
},
{
"id": "r-017",
"kind": "tool_result",
"title": "get_open_tickets(acct_4415)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5521\", \"subject\": \"July usage dispute\", \"opened\": \"2026-08-05\", \"status\": \"open\", \"assignee\": \"support-lead-2\"}]}",
},
{
"id": "r-018",
"kind": "tool_result",
"title": "get_open_tickets(acct_2210)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5502\", \"subject\": \"Login issue after SSO migration\", \"opened\": \"2026-08-01\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}",
},
{
"id": "r-019",
"kind": "external_data",
"title": "Vacation and PTO policy",
"source": "handbook",
"text": "Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.",
},
{
"id": "r-020",
"kind": "external_data",
"title": "Runbook: rotating a compromised API key",
"source": "ops-wiki",
"text": "If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.",
},
{
"id": "r-021",
"kind": "llm_response",
"text": "I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.",
},
{
"id": "r-022",
"kind": "external_data",
"title": "Customer advisory board Q4 invite draft",
"source": "marketing",
"text": "Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.",
},
{
"id": "r-023",
"kind": "tool_result",
"title": "get_account(acct_9902)",
"source": "crm-api",
"text": "{\"account_id\": \"acct_9902\", \"name\": \"Colby Fixtures\", \"plan\": \"growth\", \"payment_method\": \"card_mc_2290\", \"delinquent\": false, \"since\": \"2026-01-14\", \"owner\": \"ops@colbyfixtures.com\"}",
},
{
"id": "r-026",
"kind": "tool_result",
"title": "get_open_tickets(acct_5511)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5510\", \"subject\": \"Feature request: CSV export for usage analytics\", \"opened\": \"2026-08-03\", \"status\": \"open\", \"assignee\": \"support-lead-1\"}]}",
},
{
"id": "r-027",
"kind": "external_data",
"title": "Q3 all-hands agenda",
"source": "internal-ops",
"text": "Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.",
},
{
"id": "r-029",
"kind": "external_data",
"title": "Marketing site refresh, visual only",
"source": "marketing",
"text": "The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.",
},
{
"id": "r-031",
"kind": "tool_result",
"title": "get_open_tickets(acct_6630)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5477\", \"subject\": \"Onboarding walkthrough request\", \"opened\": \"2026-07-30\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}",
},
{
"id": "r-032",
"kind": "external_data",
"title": "On-call rotation for September",
"source": "internal-ops",
"text": "September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.",
},
{
"id": "r-033",
"kind": "external_data",
"title": "Partner co-marketing webinar recap",
"source": "marketing",
"text": "Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.",
},
{
"id": "r-034",
"kind": "external_data",
"title": "Conference room booking policy",
"source": "handbook",
"text": "Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.",
},
{
"id": "r-035",
"kind": "external_data",
"title": "Blog editorial calendar, Q4",
"source": "marketing",
"text": "Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.",
},
{
"id": "r-036",
"kind": "external_data",
"title": "Kitchen and supplies restock schedule",
"source": "internal-ops",
"text": "Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.",
},
],
"task": {
"prompt": "What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?",
"tool_name": "resolve_billing_dispute",
},
"budget": {
"max_context_tokens": 900,
"operating_point": "np-2026-08-r4",
},
"render": True,
"render_format": "plain",
"return_per_record": True,
}
r = requests.post(
"https://api.nextmoca.com/v1/context/select",
headers={"Authorization": f"Bearer {os.environ['NEEDLEPATH_API_KEY']}"},
json=payload,
timeout=10,
)
r.raise_for_status()
result = r.json()
print(result["records_selected"], "selected,", result["tokens_saved"], "tokens saved")
const payload = {
"request_id": "req-2026-09-03-0001",
"records": [
{
"id": "r-001",
"kind": "tool_result",
"title": "get_invoice(88231)",
"source": "billing-api",
"text": "{\"invoice_id\": 88231, \"account\": \"acct_4415\", \"total_cents\": 432000, \"currency\": \"usd\", \"status\": \"open\", \"issued\": \"2026-07-28\", \"due\": \"2026-08-27\", \"line_items\": [{\"sku\": \"NP-USAGE\", \"desc\": \"Metered input tokens, July\", \"qty\": 4800000, \"unit_price_cents\": 0.009}, {\"sku\": \"NP-SUPPORT\", \"desc\": \"Priority support\", \"qty\": 1, \"unit_price_cents\": 49900}]}"
},
{
"id": "r-002",
"kind": "tool_result",
"title": "get_account(acct_4415)",
"source": "crm-api",
"text": "{\"account_id\": \"acct_4415\", \"name\": \"Meridian Analytics\", \"plan\": \"scale\", \"payment_method\": \"card_visa_6411\", \"delinquent\": false, \"since\": \"2025-11-03\", \"owner\": \"dana@meridiananalytics.com\"}"
},
{
"id": "r-003",
"kind": "external_data",
"title": "Data retention policy v3",
"source": "handbook",
"text": "Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility."
},
{
"id": "r-004",
"kind": "external_data",
"title": "Refund policy v4, section 2",
"source": "handbook",
"text": "Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible."
},
{
"id": "r-005",
"kind": "external_data",
"title": "Refund policy v4, section 3 (exceptions)",
"source": "handbook",
"text": "Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered."
},
{
"id": "r-006",
"kind": "tool_result",
"title": "get_usage(acct_4415, july)",
"source": "metering-api",
"text": "{\"account_id\": \"acct_4415\", \"period\": \"2026-07\", \"input_tokens\": 4800000, \"requests\": 1210, \"stand_downs\": 34, \"charged_tokens\": 4646000}"
},
{
"id": "r-007",
"kind": "tool_result",
"title": "get_open_tickets(acct_9902)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5488\", \"subject\": \"API key rotation question\", \"opened\": \"2026-08-02\", \"status\": \"closed\", \"assignee\": \"support-lead-1\"}]}"
},
{
"id": "r-008",
"kind": "user_input",
"title": null,
"source": null,
"text": "Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?"
},
{
"id": "r-009",
"kind": "external_data",
"title": "Credit policy v2",
"source": "handbook",
"text": "Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause."
},
{
"id": "r-012",
"kind": "tool_result",
"title": "get_key_traffic(acct_4415, 2026-07-01..2026-07-19)",
"source": "metering-api",
"text": "{\"keys\": [{\"key_id\": \"np_key_a1\", \"requests\": 980, \"user_agent\": \"meridian-batch/2.1\", \"tokens\": 3100000}, {\"key_id\": \"np_key_b2\", \"requests\": 230, \"user_agent\": \"meridian-app/1.4\", \"tokens\": 1700000}], \"note\": \"np_key_a1 traffic stops 2026-07-19T14:02Z\"}"
},
{
"id": "r-013",
"kind": "external_data",
"title": "Q2 headcount planning notes",
"source": "internal-ops",
"text": "The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3."
},
{
"id": "r-014",
"kind": "tool_result",
"title": "get_invoice(55102)",
"source": "billing-api",
"text": "{\"invoice_id\": 55102, \"account\": \"acct_2210\", \"total_cents\": 18900, \"currency\": \"usd\", \"status\": \"paid\", \"issued\": \"2026-07-15\", \"due\": \"2026-08-14\"}"
},
{
"id": "r-015",
"kind": "external_data",
"title": "Q3 marketing newsletter draft",
"source": "marketing",
"text": "Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September."
},
{
"id": "r-016",
"kind": "external_data",
"title": "Office move logistics",
"source": "internal-ops",
"text": "The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes."
},
{
"id": "r-017",
"kind": "tool_result",
"title": "get_open_tickets(acct_4415)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5521\", \"subject\": \"July usage dispute\", \"opened\": \"2026-08-05\", \"status\": \"open\", \"assignee\": \"support-lead-2\"}]}"
},
{
"id": "r-018",
"kind": "tool_result",
"title": "get_open_tickets(acct_2210)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5502\", \"subject\": \"Login issue after SSO migration\", \"opened\": \"2026-08-01\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}"
},
{
"id": "r-019",
"kind": "external_data",
"title": "Vacation and PTO policy",
"source": "handbook",
"text": "Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect."
},
{
"id": "r-020",
"kind": "external_data",
"title": "Runbook: rotating a compromised API key",
"source": "ops-wiki",
"text": "If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes."
},
{
"id": "r-021",
"kind": "llm_response",
"text": "I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown."
},
{
"id": "r-022",
"kind": "external_data",
"title": "Customer advisory board Q4 invite draft",
"source": "marketing",
"text": "Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support."
},
{
"id": "r-023",
"kind": "tool_result",
"title": "get_account(acct_9902)",
"source": "crm-api",
"text": "{\"account_id\": \"acct_9902\", \"name\": \"Colby Fixtures\", \"plan\": \"growth\", \"payment_method\": \"card_mc_2290\", \"delinquent\": false, \"since\": \"2026-01-14\", \"owner\": \"ops@colbyfixtures.com\"}"
},
{
"id": "r-026",
"kind": "tool_result",
"title": "get_open_tickets(acct_5511)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5510\", \"subject\": \"Feature request: CSV export for usage analytics\", \"opened\": \"2026-08-03\", \"status\": \"open\", \"assignee\": \"support-lead-1\"}]}"
},
{
"id": "r-027",
"kind": "external_data",
"title": "Q3 all-hands agenda",
"source": "internal-ops",
"text": "Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live."
},
{
"id": "r-029",
"kind": "external_data",
"title": "Marketing site refresh, visual only",
"source": "marketing",
"text": "The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only."
},
{
"id": "r-031",
"kind": "tool_result",
"title": "get_open_tickets(acct_6630)",
"source": "support-api",
"text": "{\"tickets\": [{\"id\": \"T-5477\", \"subject\": \"Onboarding walkthrough request\", \"opened\": \"2026-07-30\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}"
},
{
"id": "r-032",
"kind": "external_data",
"title": "On-call rotation for September",
"source": "internal-ops",
"text": "September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead."
},
{
"id": "r-033",
"kind": "external_data",
"title": "Partner co-marketing webinar recap",
"source": "marketing",
"text": "Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week."
},
{
"id": "r-034",
"kind": "external_data",
"title": "Conference room booking policy",
"source": "handbook",
"text": "Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing."
},
{
"id": "r-035",
"kind": "external_data",
"title": "Blog editorial calendar, Q4",
"source": "marketing",
"text": "Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication."
},
{
"id": "r-036",
"kind": "external_data",
"title": "Kitchen and supplies restock schedule",
"source": "internal-ops",
"text": "Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week."
}
],
"task": {
"prompt": "What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?",
"tool_name": "resolve_billing_dispute"
},
"budget": {
"max_context_tokens": 900,
"operating_point": "np-2026-08-r4"
},
"render": true,
"render_format": "plain",
"return_per_record": true
};
const res = await fetch("https://api.nextmoca.com/v1/context/select", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.NEEDLEPATH_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
const result = await res.json();
console.log(result.records_selected, "selected,", result.tokens_saved, "tokens saved");
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
request_id: 'req-2026-09-03-0001',
records: [
{
id: 'r-001',
kind: 'tool_result',
title: 'get_invoice(88231)',
source: 'billing-api',
text: '{"invoice_id": 88231, "account": "acct_4415", "total_cents": 432000, "currency": "usd", "status": "open", "issued": "2026-07-28", "due": "2026-08-27", "line_items": [{"sku": "NP-USAGE", "desc": "Metered input tokens, July", "qty": 4800000, "unit_price_cents": 0.009}, {"sku": "NP-SUPPORT", "desc": "Priority support", "qty": 1, "unit_price_cents": 49900}]}'
},
{
id: 'r-002',
kind: 'tool_result',
title: 'get_account(acct_4415)',
source: 'crm-api',
text: '{"account_id": "acct_4415", "name": "Meridian Analytics", "plan": "scale", "payment_method": "card_visa_6411", "delinquent": false, "since": "2025-11-03", "owner": "dana@meridiananalytics.com"}'
},
{
id: 'r-003',
kind: 'external_data',
title: 'Data retention policy v3',
source: 'handbook',
text: 'Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.'
},
{
id: 'r-004',
kind: 'external_data',
title: 'Refund policy v4, section 2',
source: 'handbook',
text: 'Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.'
},
{
id: 'r-005',
kind: 'external_data',
title: 'Refund policy v4, section 3 (exceptions)',
source: 'handbook',
text: 'Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead\'s discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.'
},
{
id: 'r-006',
kind: 'tool_result',
title: 'get_usage(acct_4415, july)',
source: 'metering-api',
text: '{"account_id": "acct_4415", "period": "2026-07", "input_tokens": 4800000, "requests": 1210, "stand_downs": 34, "charged_tokens": 4646000}'
},
{
id: 'r-007',
kind: 'tool_result',
title: 'get_open_tickets(acct_9902)',
source: 'support-api',
text: '{"tickets": [{"id": "T-5488", "subject": "API key rotation question", "opened": "2026-08-02", "status": "closed", "assignee": "support-lead-1"}]}'
},
{
id: 'r-008',
kind: 'user_input',
title: null,
source: null,
text: 'Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?'
},
{
id: 'r-009',
kind: 'external_data',
title: 'Credit policy v2',
source: 'handbook',
text: 'Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner\'s written acknowledgement of the cause.'
},
{
id: 'r-012',
kind: 'tool_result',
title: 'get_key_traffic(acct_4415, 2026-07-01..2026-07-19)',
source: 'metering-api',
text: '{"keys": [{"key_id": "np_key_a1", "requests": 980, "user_agent": "meridian-batch/2.1", "tokens": 3100000}, {"key_id": "np_key_b2", "requests": 230, "user_agent": "meridian-app/1.4", "tokens": 1700000}], "note": "np_key_a1 traffic stops 2026-07-19T14:02Z"}'
},
{
id: 'r-013',
kind: 'external_data',
title: 'Q2 headcount planning notes',
source: 'internal-ops',
text: 'The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.'
},
{
id: 'r-014',
kind: 'tool_result',
title: 'get_invoice(55102)',
source: 'billing-api',
text: '{"invoice_id": 55102, "account": "acct_2210", "total_cents": 18900, "currency": "usd", "status": "paid", "issued": "2026-07-15", "due": "2026-08-14"}'
},
{
id: 'r-015',
kind: 'external_data',
title: 'Q3 marketing newsletter draft',
source: 'marketing',
text: 'Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.'
},
{
id: 'r-016',
kind: 'external_data',
title: 'Office move logistics',
source: 'internal-ops',
text: 'The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.'
},
{
id: 'r-017',
kind: 'tool_result',
title: 'get_open_tickets(acct_4415)',
source: 'support-api',
text: '{"tickets": [{"id": "T-5521", "subject": "July usage dispute", "opened": "2026-08-05", "status": "open", "assignee": "support-lead-2"}]}'
},
{
id: 'r-018',
kind: 'tool_result',
title: 'get_open_tickets(acct_2210)',
source: 'support-api',
text: '{"tickets": [{"id": "T-5502", "subject": "Login issue after SSO migration", "opened": "2026-08-01", "status": "closed", "assignee": "support-lead-3"}]}'
},
{
id: 'r-019',
kind: 'external_data',
title: 'Vacation and PTO policy',
source: 'handbook',
text: 'Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.'
},
{
id: 'r-020',
kind: 'external_data',
title: 'Runbook: rotating a compromised API key',
source: 'ops-wiki',
text: 'If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.'
},
{
id: 'r-021',
kind: 'llm_response',
text: 'I\'ve pulled up account acct_4415 and I\'m reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.'
},
{
id: 'r-022',
kind: 'external_data',
title: 'Customer advisory board Q4 invite draft',
source: 'marketing',
text: 'Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.'
},
{
id: 'r-023',
kind: 'tool_result',
title: 'get_account(acct_9902)',
source: 'crm-api',
text: '{"account_id": "acct_9902", "name": "Colby Fixtures", "plan": "growth", "payment_method": "card_mc_2290", "delinquent": false, "since": "2026-01-14", "owner": "ops@colbyfixtures.com"}'
},
{
id: 'r-026',
kind: 'tool_result',
title: 'get_open_tickets(acct_5511)',
source: 'support-api',
text: '{"tickets": [{"id": "T-5510", "subject": "Feature request: CSV export for usage analytics", "opened": "2026-08-03", "status": "open", "assignee": "support-lead-1"}]}'
},
{
id: 'r-027',
kind: 'external_data',
title: 'Q3 all-hands agenda',
source: 'internal-ops',
text: 'Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.'
},
{
id: 'r-029',
kind: 'external_data',
title: 'Marketing site refresh, visual only',
source: 'marketing',
text: 'The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.'
},
{
id: 'r-031',
kind: 'tool_result',
title: 'get_open_tickets(acct_6630)',
source: 'support-api',
text: '{"tickets": [{"id": "T-5477", "subject": "Onboarding walkthrough request", "opened": "2026-07-30", "status": "closed", "assignee": "support-lead-3"}]}'
},
{
id: 'r-032',
kind: 'external_data',
title: 'On-call rotation for September',
source: 'internal-ops',
text: 'September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.'
},
{
id: 'r-033',
kind: 'external_data',
title: 'Partner co-marketing webinar recap',
source: 'marketing',
text: 'Tuesday\'s co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.'
},
{
id: 'r-034',
kind: 'external_data',
title: 'Conference room booking policy',
source: 'handbook',
text: 'Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.'
},
{
id: 'r-035',
kind: 'external_data',
title: 'Blog editorial calendar, Q4',
source: 'marketing',
text: 'Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.'
},
{
id: 'r-036',
kind: 'external_data',
title: 'Kitchen and supplies restock schedule',
source: 'internal-ops',
text: 'Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.'
}
],
task: {
prompt: 'What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?',
tool_name: 'resolve_billing_dispute'
},
budget: {max_context_tokens: 900, operating_point: 'np-2026-08-r4'},
render: true,
render_format: 'plain',
return_per_record: true
})
};
fetch('https://api.nextmoca.com/v1/context/select', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nextmoca.com/v1/context/select",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'request_id' => 'req-2026-09-03-0001',
'records' => [
[
'id' => 'r-001',
'kind' => 'tool_result',
'title' => 'get_invoice(88231)',
'source' => 'billing-api',
'text' => '{"invoice_id": 88231, "account": "acct_4415", "total_cents": 432000, "currency": "usd", "status": "open", "issued": "2026-07-28", "due": "2026-08-27", "line_items": [{"sku": "NP-USAGE", "desc": "Metered input tokens, July", "qty": 4800000, "unit_price_cents": 0.009}, {"sku": "NP-SUPPORT", "desc": "Priority support", "qty": 1, "unit_price_cents": 49900}]}'
],
[
'id' => 'r-002',
'kind' => 'tool_result',
'title' => 'get_account(acct_4415)',
'source' => 'crm-api',
'text' => '{"account_id": "acct_4415", "name": "Meridian Analytics", "plan": "scale", "payment_method": "card_visa_6411", "delinquent": false, "since": "2025-11-03", "owner": "dana@meridiananalytics.com"}'
],
[
'id' => 'r-003',
'kind' => 'external_data',
'title' => 'Data retention policy v3',
'source' => 'handbook',
'text' => 'Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.'
],
[
'id' => 'r-004',
'kind' => 'external_data',
'title' => 'Refund policy v4, section 2',
'source' => 'handbook',
'text' => 'Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.'
],
[
'id' => 'r-005',
'kind' => 'external_data',
'title' => 'Refund policy v4, section 3 (exceptions)',
'source' => 'handbook',
'text' => 'Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead\'s discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.'
],
[
'id' => 'r-006',
'kind' => 'tool_result',
'title' => 'get_usage(acct_4415, july)',
'source' => 'metering-api',
'text' => '{"account_id": "acct_4415", "period": "2026-07", "input_tokens": 4800000, "requests": 1210, "stand_downs": 34, "charged_tokens": 4646000}'
],
[
'id' => 'r-007',
'kind' => 'tool_result',
'title' => 'get_open_tickets(acct_9902)',
'source' => 'support-api',
'text' => '{"tickets": [{"id": "T-5488", "subject": "API key rotation question", "opened": "2026-08-02", "status": "closed", "assignee": "support-lead-1"}]}'
],
[
'id' => 'r-008',
'kind' => 'user_input',
'title' => null,
'source' => null,
'text' => 'Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?'
],
[
'id' => 'r-009',
'kind' => 'external_data',
'title' => 'Credit policy v2',
'source' => 'handbook',
'text' => 'Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner\'s written acknowledgement of the cause.'
],
[
'id' => 'r-012',
'kind' => 'tool_result',
'title' => 'get_key_traffic(acct_4415, 2026-07-01..2026-07-19)',
'source' => 'metering-api',
'text' => '{"keys": [{"key_id": "np_key_a1", "requests": 980, "user_agent": "meridian-batch/2.1", "tokens": 3100000}, {"key_id": "np_key_b2", "requests": 230, "user_agent": "meridian-app/1.4", "tokens": 1700000}], "note": "np_key_a1 traffic stops 2026-07-19T14:02Z"}'
],
[
'id' => 'r-013',
'kind' => 'external_data',
'title' => 'Q2 headcount planning notes',
'source' => 'internal-ops',
'text' => 'The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.'
],
[
'id' => 'r-014',
'kind' => 'tool_result',
'title' => 'get_invoice(55102)',
'source' => 'billing-api',
'text' => '{"invoice_id": 55102, "account": "acct_2210", "total_cents": 18900, "currency": "usd", "status": "paid", "issued": "2026-07-15", "due": "2026-08-14"}'
],
[
'id' => 'r-015',
'kind' => 'external_data',
'title' => 'Q3 marketing newsletter draft',
'source' => 'marketing',
'text' => 'Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.'
],
[
'id' => 'r-016',
'kind' => 'external_data',
'title' => 'Office move logistics',
'source' => 'internal-ops',
'text' => 'The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.'
],
[
'id' => 'r-017',
'kind' => 'tool_result',
'title' => 'get_open_tickets(acct_4415)',
'source' => 'support-api',
'text' => '{"tickets": [{"id": "T-5521", "subject": "July usage dispute", "opened": "2026-08-05", "status": "open", "assignee": "support-lead-2"}]}'
],
[
'id' => 'r-018',
'kind' => 'tool_result',
'title' => 'get_open_tickets(acct_2210)',
'source' => 'support-api',
'text' => '{"tickets": [{"id": "T-5502", "subject": "Login issue after SSO migration", "opened": "2026-08-01", "status": "closed", "assignee": "support-lead-3"}]}'
],
[
'id' => 'r-019',
'kind' => 'external_data',
'title' => 'Vacation and PTO policy',
'source' => 'handbook',
'text' => 'Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.'
],
[
'id' => 'r-020',
'kind' => 'external_data',
'title' => 'Runbook: rotating a compromised API key',
'source' => 'ops-wiki',
'text' => 'If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.'
],
[
'id' => 'r-021',
'kind' => 'llm_response',
'text' => 'I\'ve pulled up account acct_4415 and I\'m reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.'
],
[
'id' => 'r-022',
'kind' => 'external_data',
'title' => 'Customer advisory board Q4 invite draft',
'source' => 'marketing',
'text' => 'Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.'
],
[
'id' => 'r-023',
'kind' => 'tool_result',
'title' => 'get_account(acct_9902)',
'source' => 'crm-api',
'text' => '{"account_id": "acct_9902", "name": "Colby Fixtures", "plan": "growth", "payment_method": "card_mc_2290", "delinquent": false, "since": "2026-01-14", "owner": "ops@colbyfixtures.com"}'
],
[
'id' => 'r-026',
'kind' => 'tool_result',
'title' => 'get_open_tickets(acct_5511)',
'source' => 'support-api',
'text' => '{"tickets": [{"id": "T-5510", "subject": "Feature request: CSV export for usage analytics", "opened": "2026-08-03", "status": "open", "assignee": "support-lead-1"}]}'
],
[
'id' => 'r-027',
'kind' => 'external_data',
'title' => 'Q3 all-hands agenda',
'source' => 'internal-ops',
'text' => 'Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.'
],
[
'id' => 'r-029',
'kind' => 'external_data',
'title' => 'Marketing site refresh, visual only',
'source' => 'marketing',
'text' => 'The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.'
],
[
'id' => 'r-031',
'kind' => 'tool_result',
'title' => 'get_open_tickets(acct_6630)',
'source' => 'support-api',
'text' => '{"tickets": [{"id": "T-5477", "subject": "Onboarding walkthrough request", "opened": "2026-07-30", "status": "closed", "assignee": "support-lead-3"}]}'
],
[
'id' => 'r-032',
'kind' => 'external_data',
'title' => 'On-call rotation for September',
'source' => 'internal-ops',
'text' => 'September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.'
],
[
'id' => 'r-033',
'kind' => 'external_data',
'title' => 'Partner co-marketing webinar recap',
'source' => 'marketing',
'text' => 'Tuesday\'s co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.'
],
[
'id' => 'r-034',
'kind' => 'external_data',
'title' => 'Conference room booking policy',
'source' => 'handbook',
'text' => 'Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.'
],
[
'id' => 'r-035',
'kind' => 'external_data',
'title' => 'Blog editorial calendar, Q4',
'source' => 'marketing',
'text' => 'Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.'
],
[
'id' => 'r-036',
'kind' => 'external_data',
'title' => 'Kitchen and supplies restock schedule',
'source' => 'internal-ops',
'text' => 'Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.'
]
],
'task' => [
'prompt' => 'What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?',
'tool_name' => 'resolve_billing_dispute'
],
'budget' => [
'max_context_tokens' => 900,
'operating_point' => 'np-2026-08-r4'
],
'render' => true,
'render_format' => 'plain',
'return_per_record' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nextmoca.com/v1/context/select"
payload := strings.NewReader("{\n \"request_id\": \"req-2026-09-03-0001\",\n \"records\": [\n {\n \"id\": \"r-001\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(88231)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 88231, \\\"account\\\": \\\"acct_4415\\\", \\\"total_cents\\\": 432000, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"open\\\", \\\"issued\\\": \\\"2026-07-28\\\", \\\"due\\\": \\\"2026-08-27\\\", \\\"line_items\\\": [{\\\"sku\\\": \\\"NP-USAGE\\\", \\\"desc\\\": \\\"Metered input tokens, July\\\", \\\"qty\\\": 4800000, \\\"unit_price_cents\\\": 0.009}, {\\\"sku\\\": \\\"NP-SUPPORT\\\", \\\"desc\\\": \\\"Priority support\\\", \\\"qty\\\": 1, \\\"unit_price_cents\\\": 49900}]}\"\n },\n {\n \"id\": \"r-002\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_4415)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"name\\\": \\\"Meridian Analytics\\\", \\\"plan\\\": \\\"scale\\\", \\\"payment_method\\\": \\\"card_visa_6411\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2025-11-03\\\", \\\"owner\\\": \\\"dana@meridiananalytics.com\\\"}\"\n },\n {\n \"id\": \"r-003\",\n \"kind\": \"external_data\",\n \"title\": \"Data retention policy v3\",\n \"source\": \"handbook\",\n \"text\": \"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.\"\n },\n {\n \"id\": \"r-004\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 2\",\n \"source\": \"handbook\",\n \"text\": \"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\"\n },\n {\n \"id\": \"r-005\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 3 (exceptions)\",\n \"source\": \"handbook\",\n \"text\": \"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\"\n },\n {\n \"id\": \"r-006\",\n \"kind\": \"tool_result\",\n \"title\": \"get_usage(acct_4415, july)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"period\\\": \\\"2026-07\\\", \\\"input_tokens\\\": 4800000, \\\"requests\\\": 1210, \\\"stand_downs\\\": 34, \\\"charged_tokens\\\": 4646000}\"\n },\n {\n \"id\": \"r-007\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_9902)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5488\\\", \\\"subject\\\": \\\"API key rotation question\\\", \\\"opened\\\": \\\"2026-08-02\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-008\",\n \"kind\": \"user_input\",\n \"title\": null,\n \"source\": null,\n \"text\": \"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\"\n },\n {\n \"id\": \"r-009\",\n \"kind\": \"external_data\",\n \"title\": \"Credit policy v2\",\n \"source\": \"handbook\",\n \"text\": \"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.\"\n },\n {\n \"id\": \"r-012\",\n \"kind\": \"tool_result\",\n \"title\": \"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"keys\\\": [{\\\"key_id\\\": \\\"np_key_a1\\\", \\\"requests\\\": 980, \\\"user_agent\\\": \\\"meridian-batch/2.1\\\", \\\"tokens\\\": 3100000}, {\\\"key_id\\\": \\\"np_key_b2\\\", \\\"requests\\\": 230, \\\"user_agent\\\": \\\"meridian-app/1.4\\\", \\\"tokens\\\": 1700000}], \\\"note\\\": \\\"np_key_a1 traffic stops 2026-07-19T14:02Z\\\"}\"\n },\n {\n \"id\": \"r-013\",\n \"kind\": \"external_data\",\n \"title\": \"Q2 headcount planning notes\",\n \"source\": \"internal-ops\",\n \"text\": \"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.\"\n },\n {\n \"id\": \"r-014\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(55102)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 55102, \\\"account\\\": \\\"acct_2210\\\", \\\"total_cents\\\": 18900, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"paid\\\", \\\"issued\\\": \\\"2026-07-15\\\", \\\"due\\\": \\\"2026-08-14\\\"}\"\n },\n {\n \"id\": \"r-015\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 marketing newsletter draft\",\n \"source\": \"marketing\",\n \"text\": \"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.\"\n },\n {\n \"id\": \"r-016\",\n \"kind\": \"external_data\",\n \"title\": \"Office move logistics\",\n \"source\": \"internal-ops\",\n \"text\": \"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.\"\n },\n {\n \"id\": \"r-017\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_4415)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5521\\\", \\\"subject\\\": \\\"July usage dispute\\\", \\\"opened\\\": \\\"2026-08-05\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-2\\\"}]}\"\n },\n {\n \"id\": \"r-018\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_2210)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5502\\\", \\\"subject\\\": \\\"Login issue after SSO migration\\\", \\\"opened\\\": \\\"2026-08-01\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-019\",\n \"kind\": \"external_data\",\n \"title\": \"Vacation and PTO policy\",\n \"source\": \"handbook\",\n \"text\": \"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.\"\n },\n {\n \"id\": \"r-020\",\n \"kind\": \"external_data\",\n \"title\": \"Runbook: rotating a compromised API key\",\n \"source\": \"ops-wiki\",\n \"text\": \"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.\"\n },\n {\n \"id\": \"r-021\",\n \"kind\": \"llm_response\",\n \"text\": \"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.\"\n },\n {\n \"id\": \"r-022\",\n \"kind\": \"external_data\",\n \"title\": \"Customer advisory board Q4 invite draft\",\n \"source\": \"marketing\",\n \"text\": \"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.\"\n },\n {\n \"id\": \"r-023\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_9902)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_9902\\\", \\\"name\\\": \\\"Colby Fixtures\\\", \\\"plan\\\": \\\"growth\\\", \\\"payment_method\\\": \\\"card_mc_2290\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2026-01-14\\\", \\\"owner\\\": \\\"ops@colbyfixtures.com\\\"}\"\n },\n {\n \"id\": \"r-026\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_5511)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5510\\\", \\\"subject\\\": \\\"Feature request: CSV export for usage analytics\\\", \\\"opened\\\": \\\"2026-08-03\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-027\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 all-hands agenda\",\n \"source\": \"internal-ops\",\n \"text\": \"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.\"\n },\n {\n \"id\": \"r-029\",\n \"kind\": \"external_data\",\n \"title\": \"Marketing site refresh, visual only\",\n \"source\": \"marketing\",\n \"text\": \"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.\"\n },\n {\n \"id\": \"r-031\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_6630)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5477\\\", \\\"subject\\\": \\\"Onboarding walkthrough request\\\", \\\"opened\\\": \\\"2026-07-30\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-032\",\n \"kind\": \"external_data\",\n \"title\": \"On-call rotation for September\",\n \"source\": \"internal-ops\",\n \"text\": \"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.\"\n },\n {\n \"id\": \"r-033\",\n \"kind\": \"external_data\",\n \"title\": \"Partner co-marketing webinar recap\",\n \"source\": \"marketing\",\n \"text\": \"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.\"\n },\n {\n \"id\": \"r-034\",\n \"kind\": \"external_data\",\n \"title\": \"Conference room booking policy\",\n \"source\": \"handbook\",\n \"text\": \"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.\"\n },\n {\n \"id\": \"r-035\",\n \"kind\": \"external_data\",\n \"title\": \"Blog editorial calendar, Q4\",\n \"source\": \"marketing\",\n \"text\": \"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.\"\n },\n {\n \"id\": \"r-036\",\n \"kind\": \"external_data\",\n \"title\": \"Kitchen and supplies restock schedule\",\n \"source\": \"internal-ops\",\n \"text\": \"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.\"\n }\n ],\n \"task\": {\n \"prompt\": \"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?\",\n \"tool_name\": \"resolve_billing_dispute\"\n },\n \"budget\": {\n \"max_context_tokens\": 900,\n \"operating_point\": \"np-2026-08-r4\"\n },\n \"render\": true,\n \"render_format\": \"plain\",\n \"return_per_record\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://api.nextmoca.com/v1/context/select")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"request_id\": \"req-2026-09-03-0001\",\n \"records\": [\n {\n \"id\": \"r-001\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(88231)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 88231, \\\"account\\\": \\\"acct_4415\\\", \\\"total_cents\\\": 432000, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"open\\\", \\\"issued\\\": \\\"2026-07-28\\\", \\\"due\\\": \\\"2026-08-27\\\", \\\"line_items\\\": [{\\\"sku\\\": \\\"NP-USAGE\\\", \\\"desc\\\": \\\"Metered input tokens, July\\\", \\\"qty\\\": 4800000, \\\"unit_price_cents\\\": 0.009}, {\\\"sku\\\": \\\"NP-SUPPORT\\\", \\\"desc\\\": \\\"Priority support\\\", \\\"qty\\\": 1, \\\"unit_price_cents\\\": 49900}]}\"\n },\n {\n \"id\": \"r-002\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_4415)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"name\\\": \\\"Meridian Analytics\\\", \\\"plan\\\": \\\"scale\\\", \\\"payment_method\\\": \\\"card_visa_6411\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2025-11-03\\\", \\\"owner\\\": \\\"dana@meridiananalytics.com\\\"}\"\n },\n {\n \"id\": \"r-003\",\n \"kind\": \"external_data\",\n \"title\": \"Data retention policy v3\",\n \"source\": \"handbook\",\n \"text\": \"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.\"\n },\n {\n \"id\": \"r-004\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 2\",\n \"source\": \"handbook\",\n \"text\": \"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\"\n },\n {\n \"id\": \"r-005\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 3 (exceptions)\",\n \"source\": \"handbook\",\n \"text\": \"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\"\n },\n {\n \"id\": \"r-006\",\n \"kind\": \"tool_result\",\n \"title\": \"get_usage(acct_4415, july)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"period\\\": \\\"2026-07\\\", \\\"input_tokens\\\": 4800000, \\\"requests\\\": 1210, \\\"stand_downs\\\": 34, \\\"charged_tokens\\\": 4646000}\"\n },\n {\n \"id\": \"r-007\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_9902)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5488\\\", \\\"subject\\\": \\\"API key rotation question\\\", \\\"opened\\\": \\\"2026-08-02\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-008\",\n \"kind\": \"user_input\",\n \"title\": null,\n \"source\": null,\n \"text\": \"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\"\n },\n {\n \"id\": \"r-009\",\n \"kind\": \"external_data\",\n \"title\": \"Credit policy v2\",\n \"source\": \"handbook\",\n \"text\": \"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.\"\n },\n {\n \"id\": \"r-012\",\n \"kind\": \"tool_result\",\n \"title\": \"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"keys\\\": [{\\\"key_id\\\": \\\"np_key_a1\\\", \\\"requests\\\": 980, \\\"user_agent\\\": \\\"meridian-batch/2.1\\\", \\\"tokens\\\": 3100000}, {\\\"key_id\\\": \\\"np_key_b2\\\", \\\"requests\\\": 230, \\\"user_agent\\\": \\\"meridian-app/1.4\\\", \\\"tokens\\\": 1700000}], \\\"note\\\": \\\"np_key_a1 traffic stops 2026-07-19T14:02Z\\\"}\"\n },\n {\n \"id\": \"r-013\",\n \"kind\": \"external_data\",\n \"title\": \"Q2 headcount planning notes\",\n \"source\": \"internal-ops\",\n \"text\": \"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.\"\n },\n {\n \"id\": \"r-014\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(55102)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 55102, \\\"account\\\": \\\"acct_2210\\\", \\\"total_cents\\\": 18900, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"paid\\\", \\\"issued\\\": \\\"2026-07-15\\\", \\\"due\\\": \\\"2026-08-14\\\"}\"\n },\n {\n \"id\": \"r-015\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 marketing newsletter draft\",\n \"source\": \"marketing\",\n \"text\": \"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.\"\n },\n {\n \"id\": \"r-016\",\n \"kind\": \"external_data\",\n \"title\": \"Office move logistics\",\n \"source\": \"internal-ops\",\n \"text\": \"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.\"\n },\n {\n \"id\": \"r-017\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_4415)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5521\\\", \\\"subject\\\": \\\"July usage dispute\\\", \\\"opened\\\": \\\"2026-08-05\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-2\\\"}]}\"\n },\n {\n \"id\": \"r-018\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_2210)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5502\\\", \\\"subject\\\": \\\"Login issue after SSO migration\\\", \\\"opened\\\": \\\"2026-08-01\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-019\",\n \"kind\": \"external_data\",\n \"title\": \"Vacation and PTO policy\",\n \"source\": \"handbook\",\n \"text\": \"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.\"\n },\n {\n \"id\": \"r-020\",\n \"kind\": \"external_data\",\n \"title\": \"Runbook: rotating a compromised API key\",\n \"source\": \"ops-wiki\",\n \"text\": \"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.\"\n },\n {\n \"id\": \"r-021\",\n \"kind\": \"llm_response\",\n \"text\": \"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.\"\n },\n {\n \"id\": \"r-022\",\n \"kind\": \"external_data\",\n \"title\": \"Customer advisory board Q4 invite draft\",\n \"source\": \"marketing\",\n \"text\": \"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.\"\n },\n {\n \"id\": \"r-023\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_9902)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_9902\\\", \\\"name\\\": \\\"Colby Fixtures\\\", \\\"plan\\\": \\\"growth\\\", \\\"payment_method\\\": \\\"card_mc_2290\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2026-01-14\\\", \\\"owner\\\": \\\"ops@colbyfixtures.com\\\"}\"\n },\n {\n \"id\": \"r-026\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_5511)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5510\\\", \\\"subject\\\": \\\"Feature request: CSV export for usage analytics\\\", \\\"opened\\\": \\\"2026-08-03\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-027\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 all-hands agenda\",\n \"source\": \"internal-ops\",\n \"text\": \"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.\"\n },\n {\n \"id\": \"r-029\",\n \"kind\": \"external_data\",\n \"title\": \"Marketing site refresh, visual only\",\n \"source\": \"marketing\",\n \"text\": \"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.\"\n },\n {\n \"id\": \"r-031\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_6630)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5477\\\", \\\"subject\\\": \\\"Onboarding walkthrough request\\\", \\\"opened\\\": \\\"2026-07-30\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-032\",\n \"kind\": \"external_data\",\n \"title\": \"On-call rotation for September\",\n \"source\": \"internal-ops\",\n \"text\": \"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.\"\n },\n {\n \"id\": \"r-033\",\n \"kind\": \"external_data\",\n \"title\": \"Partner co-marketing webinar recap\",\n \"source\": \"marketing\",\n \"text\": \"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.\"\n },\n {\n \"id\": \"r-034\",\n \"kind\": \"external_data\",\n \"title\": \"Conference room booking policy\",\n \"source\": \"handbook\",\n \"text\": \"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.\"\n },\n {\n \"id\": \"r-035\",\n \"kind\": \"external_data\",\n \"title\": \"Blog editorial calendar, Q4\",\n \"source\": \"marketing\",\n \"text\": \"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.\"\n },\n {\n \"id\": \"r-036\",\n \"kind\": \"external_data\",\n \"title\": \"Kitchen and supplies restock schedule\",\n \"source\": \"internal-ops\",\n \"text\": \"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.\"\n }\n ],\n \"task\": {\n \"prompt\": \"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?\",\n \"tool_name\": \"resolve_billing_dispute\"\n },\n \"budget\": {\n \"max_context_tokens\": 900,\n \"operating_point\": \"np-2026-08-r4\"\n },\n \"render\": true,\n \"render_format\": \"plain\",\n \"return_per_record\": true\n}")
.asString();
require 'uri'
require 'net/http'
url = URI("https://api.nextmoca.com/v1/context/select")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"request_id\": \"req-2026-09-03-0001\",\n \"records\": [\n {\n \"id\": \"r-001\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(88231)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 88231, \\\"account\\\": \\\"acct_4415\\\", \\\"total_cents\\\": 432000, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"open\\\", \\\"issued\\\": \\\"2026-07-28\\\", \\\"due\\\": \\\"2026-08-27\\\", \\\"line_items\\\": [{\\\"sku\\\": \\\"NP-USAGE\\\", \\\"desc\\\": \\\"Metered input tokens, July\\\", \\\"qty\\\": 4800000, \\\"unit_price_cents\\\": 0.009}, {\\\"sku\\\": \\\"NP-SUPPORT\\\", \\\"desc\\\": \\\"Priority support\\\", \\\"qty\\\": 1, \\\"unit_price_cents\\\": 49900}]}\"\n },\n {\n \"id\": \"r-002\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_4415)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"name\\\": \\\"Meridian Analytics\\\", \\\"plan\\\": \\\"scale\\\", \\\"payment_method\\\": \\\"card_visa_6411\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2025-11-03\\\", \\\"owner\\\": \\\"dana@meridiananalytics.com\\\"}\"\n },\n {\n \"id\": \"r-003\",\n \"kind\": \"external_data\",\n \"title\": \"Data retention policy v3\",\n \"source\": \"handbook\",\n \"text\": \"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.\"\n },\n {\n \"id\": \"r-004\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 2\",\n \"source\": \"handbook\",\n \"text\": \"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\"\n },\n {\n \"id\": \"r-005\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 3 (exceptions)\",\n \"source\": \"handbook\",\n \"text\": \"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\"\n },\n {\n \"id\": \"r-006\",\n \"kind\": \"tool_result\",\n \"title\": \"get_usage(acct_4415, july)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"period\\\": \\\"2026-07\\\", \\\"input_tokens\\\": 4800000, \\\"requests\\\": 1210, \\\"stand_downs\\\": 34, \\\"charged_tokens\\\": 4646000}\"\n },\n {\n \"id\": \"r-007\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_9902)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5488\\\", \\\"subject\\\": \\\"API key rotation question\\\", \\\"opened\\\": \\\"2026-08-02\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-008\",\n \"kind\": \"user_input\",\n \"title\": null,\n \"source\": null,\n \"text\": \"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\"\n },\n {\n \"id\": \"r-009\",\n \"kind\": \"external_data\",\n \"title\": \"Credit policy v2\",\n \"source\": \"handbook\",\n \"text\": \"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.\"\n },\n {\n \"id\": \"r-012\",\n \"kind\": \"tool_result\",\n \"title\": \"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"keys\\\": [{\\\"key_id\\\": \\\"np_key_a1\\\", \\\"requests\\\": 980, \\\"user_agent\\\": \\\"meridian-batch/2.1\\\", \\\"tokens\\\": 3100000}, {\\\"key_id\\\": \\\"np_key_b2\\\", \\\"requests\\\": 230, \\\"user_agent\\\": \\\"meridian-app/1.4\\\", \\\"tokens\\\": 1700000}], \\\"note\\\": \\\"np_key_a1 traffic stops 2026-07-19T14:02Z\\\"}\"\n },\n {\n \"id\": \"r-013\",\n \"kind\": \"external_data\",\n \"title\": \"Q2 headcount planning notes\",\n \"source\": \"internal-ops\",\n \"text\": \"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.\"\n },\n {\n \"id\": \"r-014\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(55102)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 55102, \\\"account\\\": \\\"acct_2210\\\", \\\"total_cents\\\": 18900, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"paid\\\", \\\"issued\\\": \\\"2026-07-15\\\", \\\"due\\\": \\\"2026-08-14\\\"}\"\n },\n {\n \"id\": \"r-015\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 marketing newsletter draft\",\n \"source\": \"marketing\",\n \"text\": \"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.\"\n },\n {\n \"id\": \"r-016\",\n \"kind\": \"external_data\",\n \"title\": \"Office move logistics\",\n \"source\": \"internal-ops\",\n \"text\": \"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.\"\n },\n {\n \"id\": \"r-017\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_4415)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5521\\\", \\\"subject\\\": \\\"July usage dispute\\\", \\\"opened\\\": \\\"2026-08-05\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-2\\\"}]}\"\n },\n {\n \"id\": \"r-018\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_2210)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5502\\\", \\\"subject\\\": \\\"Login issue after SSO migration\\\", \\\"opened\\\": \\\"2026-08-01\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-019\",\n \"kind\": \"external_data\",\n \"title\": \"Vacation and PTO policy\",\n \"source\": \"handbook\",\n \"text\": \"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.\"\n },\n {\n \"id\": \"r-020\",\n \"kind\": \"external_data\",\n \"title\": \"Runbook: rotating a compromised API key\",\n \"source\": \"ops-wiki\",\n \"text\": \"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.\"\n },\n {\n \"id\": \"r-021\",\n \"kind\": \"llm_response\",\n \"text\": \"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.\"\n },\n {\n \"id\": \"r-022\",\n \"kind\": \"external_data\",\n \"title\": \"Customer advisory board Q4 invite draft\",\n \"source\": \"marketing\",\n \"text\": \"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.\"\n },\n {\n \"id\": \"r-023\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_9902)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_9902\\\", \\\"name\\\": \\\"Colby Fixtures\\\", \\\"plan\\\": \\\"growth\\\", \\\"payment_method\\\": \\\"card_mc_2290\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2026-01-14\\\", \\\"owner\\\": \\\"ops@colbyfixtures.com\\\"}\"\n },\n {\n \"id\": \"r-026\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_5511)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5510\\\", \\\"subject\\\": \\\"Feature request: CSV export for usage analytics\\\", \\\"opened\\\": \\\"2026-08-03\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-027\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 all-hands agenda\",\n \"source\": \"internal-ops\",\n \"text\": \"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.\"\n },\n {\n \"id\": \"r-029\",\n \"kind\": \"external_data\",\n \"title\": \"Marketing site refresh, visual only\",\n \"source\": \"marketing\",\n \"text\": \"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.\"\n },\n {\n \"id\": \"r-031\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_6630)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5477\\\", \\\"subject\\\": \\\"Onboarding walkthrough request\\\", \\\"opened\\\": \\\"2026-07-30\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-032\",\n \"kind\": \"external_data\",\n \"title\": \"On-call rotation for September\",\n \"source\": \"internal-ops\",\n \"text\": \"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.\"\n },\n {\n \"id\": \"r-033\",\n \"kind\": \"external_data\",\n \"title\": \"Partner co-marketing webinar recap\",\n \"source\": \"marketing\",\n \"text\": \"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.\"\n },\n {\n \"id\": \"r-034\",\n \"kind\": \"external_data\",\n \"title\": \"Conference room booking policy\",\n \"source\": \"handbook\",\n \"text\": \"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.\"\n },\n {\n \"id\": \"r-035\",\n \"kind\": \"external_data\",\n \"title\": \"Blog editorial calendar, Q4\",\n \"source\": \"marketing\",\n \"text\": \"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.\"\n },\n {\n \"id\": \"r-036\",\n \"kind\": \"external_data\",\n \"title\": \"Kitchen and supplies restock schedule\",\n \"source\": \"internal-ops\",\n \"text\": \"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.\"\n }\n ],\n \"task\": {\n \"prompt\": \"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?\",\n \"tool_name\": \"resolve_billing_dispute\"\n },\n \"budget\": {\n \"max_context_tokens\": 900,\n \"operating_point\": \"np-2026-08-r4\"\n },\n \"render\": true,\n \"render_format\": \"plain\",\n \"return_per_record\": true\n}"
response = http.request(request)
puts response.read_body
{ "request_id": "req-2026-09-03-0001", "rendered_context": "Relevant State\n\n1. Credit policy v2 (handbook)\nService credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method.\nCredits require the account owner's written acknowledgement of the cause.\n\n2. user_input\nCustomer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\n\n3. Refund policy v4, section 3 (exceptions) (handbook)\nException: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\n\n4. Refund policy v4, section 2 (handbook)\nRefunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\n\n5. llm_response\nI've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.", "policy_version": "np-2026-08-r4", "selected": [ { "record_id": "r-009", "kind": "external_data", "title": "Credit policy v2", "source": "handbook", "score": 32.658829095499584, "reason": "hard context: answer-bearing evidence: keyword overlap", "excerpt": "Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method.\nCredits require the account owner's written acknowledgement of the cause.", "excerpt_format": "plain", "selected_tokens": 76 }, { "record_id": "r-008", "kind": "user_input", "title": null, "source": null, "score": 54.106697605930485, "reason": "hard context: weighted evidence coverage: current request; keyword overlap; semantic tag overlap", "excerpt": "Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?", "excerpt_format": "plain", "selected_tokens": 60 }, { "record_id": "r-005", "kind": "external_data", "title": "Refund policy v4, section 3 (exceptions)", "source": "handbook", "score": 13.458636537340059, "reason": "hard context: weighted evidence coverage: keyword overlap", "excerpt": "Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.", "excerpt_format": "plain", "selected_tokens": 67 }, { "record_id": "r-004", "kind": "external_data", "title": "Refund policy v4, section 2", "source": "handbook", "score": 14.01558939758398, "reason": "hard context: recent relevant result: keyword overlap", "excerpt": "Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.", "excerpt_format": "plain", "selected_tokens": 74 }, { "record_id": "r-021", "kind": "llm_response", "title": null, "source": null, "score": 14.644259731672935, "reason": "soft context: keyword overlap", "excerpt": "I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.", "excerpt_format": "plain", "selected_tokens": 37 } ], "tokens_before": 1775, "tokens_after": 314, "tokens_saved": 1461, "records_available": 30, "records_selected": 5, "fallback_used": false, "selection_error": null, "engine_latency_ms": 7.534137000220653, "budget_tokens": 900, "attempted_budget_tokens": [ 900 ], "reduction_ratio": 0.8230985915492958, "safety": { "selection_safe": true, "fallback_required": false, "fallback_reason": "", "coverage_score": 1, "evidence_shape": "exact_anchor_lookup", "evidence_terms": null, "repair_reasons": [] }, "gate": { "engaged": true, "reason": "engage:delivered_support_complete", "signals": { "n_candidates": 21, "high_drift": false } }, "format_metrics": { "context_format": "plain", "formatted_context_tokens": 361, "plain_context_tokens": 361, "toon_context_tokens": null, "toon_applied": false, "whole_context_toon_applied": false, "structured_toon_excerpts": 0, "structured_toon_tokens_saved": 0, "toon_tokens_saved_vs_plain": 0, "selection_strategy_used": "fast", "selection_strategy_initial": "fast", "support_contract_used": "generic", "adapter_attempt_count": 1, "semantic_adapter_ids": [ "generic" ], "semantic_routing_bounds_hit": false, "semantic_adapter_registry_version": "np-adapters-2026-08-r1", "semantic_router_version": "np-router-2026-08-r3", "semantic_normalizer_version": "np-normalizer-2026-08-r1", "support_contract_resolution_version": "np-support-resolution-2026-08-r3", "attempted_recall_rungs": [ { "candidate_limit": 250, "min_selection_score": 8, "max_selected_records": 18, "max_selected_tokens": 900 } ] }, "selection_strategy_used": "fast", "support_contract_used": "generic", "adapter_attempt_count": 1, "usage": { "meter_version": "npm-2026-08-r1", "outcome": "engaged", "input_tokens": 1998, "charge_multiplier": "1.0", "price_version": "npp-2026-10-r1", "currency": "USD" }, "outcome": "engaged", "records_submitted": 30, "records_admitted": 30, "candidates_truncated": false, "selection_recall": { "version": "npsr-2026-08-r2", "operating_point": "np-2026-08-r4", "records_submitted": 30, "records_admitted": 30, "candidate_matches_total": 21, "candidates_scored": 21, "candidates_above_floor": 5, "records_selected": 5, "candidate_limit_hit": false, "weighted_term_coverage": 0.4838709677419355, "excerpt_term_coverage": 0.44086021505376344, "rejection_counts": { "hard_entity_conflict": 0, "secret_payload": 0, "below_selection_floor": 16, "record_count_budget": 0, "token_budget": 0, "excerpt_coverage_loss": 0 }, "evidence_confidence_score": 1, "lexical_coverage": 0.44086021505376344 }, "task_kind": "pointed"}
One credential form. There is no query-parameter, cookie or
x-api-key alternative. The legacy x-api-key header stopped being
accepted at the Bearer cutover and now fails authorization.
Keys are org-scoped, never user-scoped, and the secret is shown
exactly once at mint. Rotation is create-then-revoke.
Body
application/json
Either ContextRequest (typed records[]) or
SimpleTextContextRequest (free-form text); never both. Maximum
body size is 6 MB, the AWS Lambda synchronous payload cap. API
Gateway rejects an oversized body before the service is invoked, so
guard it client-side rather than relying on a readable error.
The records Needlepath may keep, drop or excerpt. An empty array is
accepted and yields an empty selection. Record order breaks score
ties, and record count is capped per request alongside the token
ceiling. See Limits and Records and tasks.
Show child attributes
Example:
[ { "id": "r-001", "kind": "tool_result", "title": "get_invoice(88231)", "source": "billing-api", "text": "{\"invoice_id\": 88231, \"account\": \"acct_4415\", \"total_cents\": 432000, \"currency\": \"usd\", \"status\": \"open\", \"issued\": \"2026-07-28\", \"due\": \"2026-08-27\", \"line_items\": [{\"sku\": \"NP-USAGE\", \"desc\": \"Metered input tokens, July\", \"qty\": 4800000, \"unit_price_cents\": 0.009}, {\"sku\": \"NP-SUPPORT\", \"desc\": \"Priority support\", \"qty\": 1, \"unit_price_cents\": 49900}]}" }, { "id": "r-002", "kind": "tool_result", "title": "get_account(acct_4415)", "source": "crm-api", "text": "{\"account_id\": \"acct_4415\", \"name\": \"Meridian Analytics\", \"plan\": \"scale\", \"payment_method\": \"card_visa_6411\", \"delinquent\": false, \"since\": \"2025-11-03\", \"owner\": \"dana@meridiananalytics.com\"}" }, { "id": "r-003", "kind": "external_data", "title": "Data retention policy v3", "source": "handbook", "text": "Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility." }, { "id": "r-004", "kind": "external_data", "title": "Refund policy v4, section 2", "source": "handbook", "text": "Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible." }, { "id": "r-005", "kind": "external_data", "title": "Refund policy v4, section 3 (exceptions)", "source": "handbook", "text": "Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered." }, { "id": "r-006", "kind": "tool_result", "title": "get_usage(acct_4415, july)", "source": "metering-api", "text": "{\"account_id\": \"acct_4415\", \"period\": \"2026-07\", \"input_tokens\": 4800000, \"requests\": 1210, \"stand_downs\": 34, \"charged_tokens\": 4646000}" }, { "id": "r-007", "kind": "tool_result", "title": "get_open_tickets(acct_9902)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5488\", \"subject\": \"API key rotation question\", \"opened\": \"2026-08-02\", \"status\": \"closed\", \"assignee\": \"support-lead-1\"}]}" }, { "id": "r-008", "kind": "user_input", "title": null, "source": null, "text": "Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?" }, { "id": "r-009", "kind": "external_data", "title": "Credit policy v2", "source": "handbook", "text": "Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause." }, { "id": "r-012", "kind": "tool_result", "title": "get_key_traffic(acct_4415, 2026-07-01..2026-07-19)", "source": "metering-api", "text": "{\"keys\": [{\"key_id\": \"np_key_a1\", \"requests\": 980, \"user_agent\": \"meridian-batch/2.1\", \"tokens\": 3100000}, {\"key_id\": \"np_key_b2\", \"requests\": 230, \"user_agent\": \"meridian-app/1.4\", \"tokens\": 1700000}], \"note\": \"np_key_a1 traffic stops 2026-07-19T14:02Z\"}" }, { "id": "r-013", "kind": "external_data", "title": "Q2 headcount planning notes", "source": "internal-ops", "text": "The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3." }, { "id": "r-014", "kind": "tool_result", "title": "get_invoice(55102)", "source": "billing-api", "text": "{\"invoice_id\": 55102, \"account\": \"acct_2210\", \"total_cents\": 18900, \"currency\": \"usd\", \"status\": \"paid\", \"issued\": \"2026-07-15\", \"due\": \"2026-08-14\"}" }, { "id": "r-015", "kind": "external_data", "title": "Q3 marketing newsletter draft", "source": "marketing", "text": "Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September." }, { "id": "r-016", "kind": "external_data", "title": "Office move logistics", "source": "internal-ops", "text": "The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes." }, { "id": "r-017", "kind": "tool_result", "title": "get_open_tickets(acct_4415)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5521\", \"subject\": \"July usage dispute\", \"opened\": \"2026-08-05\", \"status\": \"open\", \"assignee\": \"support-lead-2\"}]}" }, { "id": "r-018", "kind": "tool_result", "title": "get_open_tickets(acct_2210)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5502\", \"subject\": \"Login issue after SSO migration\", \"opened\": \"2026-08-01\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}" }, { "id": "r-019", "kind": "external_data", "title": "Vacation and PTO policy", "source": "handbook", "text": "Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect." }, { "id": "r-020", "kind": "external_data", "title": "Runbook: rotating a compromised API key", "source": "ops-wiki", "text": "If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes." }, { "id": "r-021", "kind": "llm_response", "text": "I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown." }, { "id": "r-022", "kind": "external_data", "title": "Customer advisory board Q4 invite draft", "source": "marketing", "text": "Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support." }, { "id": "r-023", "kind": "tool_result", "title": "get_account(acct_9902)", "source": "crm-api", "text": "{\"account_id\": \"acct_9902\", \"name\": \"Colby Fixtures\", \"plan\": \"growth\", \"payment_method\": \"card_mc_2290\", \"delinquent\": false, \"since\": \"2026-01-14\", \"owner\": \"ops@colbyfixtures.com\"}" }, { "id": "r-026", "kind": "tool_result", "title": "get_open_tickets(acct_5511)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5510\", \"subject\": \"Feature request: CSV export for usage analytics\", \"opened\": \"2026-08-03\", \"status\": \"open\", \"assignee\": \"support-lead-1\"}]}" }, { "id": "r-027", "kind": "external_data", "title": "Q3 all-hands agenda", "source": "internal-ops", "text": "Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q&A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live." }, { "id": "r-029", "kind": "external_data", "title": "Marketing site refresh, visual only", "source": "marketing", "text": "The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only." }, { "id": "r-031", "kind": "tool_result", "title": "get_open_tickets(acct_6630)", "source": "support-api", "text": "{\"tickets\": [{\"id\": \"T-5477\", \"subject\": \"Onboarding walkthrough request\", \"opened\": \"2026-07-30\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}" }, { "id": "r-032", "kind": "external_data", "title": "On-call rotation for September", "source": "internal-ops", "text": "September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead." }, { "id": "r-033", "kind": "external_data", "title": "Partner co-marketing webinar recap", "source": "marketing", "text": "Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week." }, { "id": "r-034", "kind": "external_data", "title": "Conference room booking policy", "source": "handbook", "text": "Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing." }, { "id": "r-035", "kind": "external_data", "title": "Blog editorial calendar, Q4", "source": "marketing", "text": "Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication." }, { "id": "r-036", "kind": "external_data", "title": "Kitchen and supplies restock schedule", "source": "internal-ops", "text": "Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week." } ]
{ "prompt": "What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?", "tool_name": "resolve_billing_dispute" }
The operating point, in arm-neutral quantities only. No method-tuning
knobs appear here or anywhere else in the request: the selection
configuration resolves server-side from the operating_point label.
Your correlation id, echoed back byte-for-byte. Optional:
it is sent-side only, a caller correlation id we never require;
absent is echoed back as "". When sent, keep it to ≤ 128
characters of [A-Za-z0-9._:-], and put no record content,
customer text or credentials in it, because it reaches our logs. See
Retention and trust.
Ask for rendered_context, a model-facing string assembled from the
selection. render has no effect; rendered_context is always
returned. Ignore it client-side if unwanted.
plain leaves excerpts as text. hybrid additionally permits a
structured excerpt to be re-encoded into a more compact form, and
excerpt_format reports which form was used.
Send plain if you re-parse excerpts as JSON.
Include the selected[] per-record detail: score, reason, excerpt
and token count. Set false for rendered_context plus the token
arithmetic only, which is a materially smaller response body.
Security screening of the context this request delivers. Per request,
and available to any caller. Omitted, the request keeps the operating
point's setting: enforce on np-2026-10-r7 and np-2026-10-r8, and off
on every other listed operating point. Sent, it replaces that setting for this request
only.
audit screens and reports in the receipt without changing what is
delivered. quarantine removes flagged spans from the delivered context
and marks each removal in place. enforce does the same and, when nothing
deliverable remains, returns outcome: blocked with no context. See
Errors for the two outcomes and How billing works for the charge.
Available options:
off,
audit,
quarantine,
enforce
Example:
"audit"
Response
A selection. Includes stand-downs and engine-internal failures,
so read fallback_used and selection_error. This service returns 200
with a usable body rather than a 5xx when its own selection pass
fails, because the correct client behaviour in that case is to send
the original context, which the body already contains.
The selection.
Required by the contract (the published client raises if any is
missing, or if request_id does not echo): request_id,
rendered_context, tokens_before, tokens_after, tokens_saved,
records_available, records_selected, fallback_used, outcome,
engine_latency_ms.
Everything else is optional and new optional fields ship within
/v1, so ignore what you do not recognise.
This object is open, and it already carries keys this schema does not
list. Some are operating-point specific, so the exact set varies with
the operating_point you send. A generated client must tolerate unknown
keys rather than reject or drop the response: validate the required
fields above and pass the rest through. If your generator defaults
additionalProperties to false, it will produce a client that current
responses already fail.
The model-facing block, assembled from the selection. Always returned.
When security screening removed a span, the removed text is replaced in
place by the marker [QUARANTINED: instruction-like candidate text removed];
on outcome: blocked this is a placeholder line with none of your content.
The engine's own accounting of the context available before
filtering. It is not the billing quantity: the meter also counts
record.title, task.prompt and task.recent_prompts, so
usage.input_tokens is the larger number. Budget against this, do
not reconcile an invoice with it. See How to recompute your own
bill.
How the engine resolved this request, at the top level so that you never have to read a nested object to find it.
An open enum. Do not exhaustively match it, and do not fail closed on a value you do not recognise: new outcomes ship additively within /v1. Current values are engaged (records were selected), escalated (the eligible full context exceeded the capacity it had to fit inside, so selected is empty and rendered_context is an empty string), stood_down (Needlepath stood down: no selection was returned, so send your full input), and two that appear only when security screening ran, because the request sent security_mode or ran on np-2026-10-r7 or np-2026-10-r8: sanitized_fallback (a full-context fallback delivered as rendered_context with flagged spans removed and marked in place; records_selected is 0 and fallback_used is false, so send rendered_context) and blocked (under enforce, nothing deliverable remained; no context is returned). See Errors.
This is not the same field as usage.outcome, and the two can legitimately disagree on a single response. This field reports what the engine did. usage.outcome reports how the request was priced, and it resolves selection failures first, so a response can carry outcome: "engaged" alongside usage.outcome: "fallback". Read this field to decide what to do with the response; read usage.outcome to explain a charge.
escalated returns no context. Treat it as "use the context you already had". It is not an error, and it is not a saving. blocked returns no context either; the published clients treat it as a decline and continue with the context you already had, and it is charged.
true means send the context you submitted: the response returns it
essentially intact. It does not tell you why: a stand-down (an empty
selection with outcome: stood_down, or every record returned), an empty
record set and an engine-internal
exception all produce it. Read outcome first, then selection_error
and format_metrics.engine_fallback_reason to tell the last two apart.
Do not read gate for this: it can disagree with outcome.
See Errors.
Server-measured selection time, excluding network transit, so it is
not your round trip. Example values in this document are
illustrative and are not a performance commitment.
The frozen version behind the operating_point that actually ran.
Record it with every result: it is how you detect that you inherited
a default you did not choose.
Per-record detail, in selection order. Empty when you sent
return_per_record: falseand also empty on some stand-downs, so
read records_selected rather than the array length.
How many extra candidates budget.autochunk produced: the candidate
count minus the number of records you sent. Present only on requests
that set budget.autochunk, and absent -- not zero -- on every other
request, so that its absence cannot be read as "autochunk ran and split
nothing".
Set when the engine's own selection pass raised. The HTTP status is
still 200 and the body carries a usable full-context result. Alarm
on this field, not on 5xx.
Every rung attempted on the adaptive ladder, in order. Empty on the fixed path. Watch it to see whether an adaptive workload is doing several selection passes per request.
Present on some responses, and null on np-2026-07-r2's
fixed-budget path. A null safety means the response carries no
safety summary, never that the selection was sound.
Free-form, additive rendering and diagnostic telemetry. Treat unknown
keys as informational. Keys you may see:
engine_fallback_reason: present only on a fallback response,
carrying its own reason.
request_id_sanitized: true: your request_id broke the length
or charset bound and the internal copy was truncated. Your echo is
still your bytes.
client_latency_ms: added by the published client, not by the
server.
security_mode, security_action, security_findings_count,
security_source_kinds: present only when security screening ran,
that is when the request sent a security_mode other than off, or
ran on np-2026-10-r7 or np-2026-10-r8 without sending off.
The mode that applied; what screening did (keep, audit,
quarantine or block); how many spans were flagged; and the
provenance kinds of the records it read. See Errors.
The metering receipt for this request. See How billing works.
Show child attributes
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Needlepath","description":"Select which context records enter a model call, verbatim.","colors":{"primary":"#C97B47","light":"#E8A87C","dark":"#8A4F2C"},"favicon":"https://mintcdn.com/next-moca-global-inc/xLBqpVyqnZ2xtoFP/favicon.png?fit=max\u0026auto=format\u0026n=xLBqpVyqnZ2xtoFP\u0026q=85\u0026s=ce869f1d135cc36e8df076c0bc80a78d","api":{"examples":{"prefill":true}},"appearance":{"default":"dark"},"navbar":{"links":[],"primary":{"type":"button","label":"Get an API key","href":"https://docs.nextmoca.com/authentication#getting-an-api-key"}},"footer":{"socials":{"website":"https://nextmoca.com"}},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"next-moca-global-inc","hasAudioNarration":false,"actualSubdomain":"next-moca-global-inc","customDomains":["docs.nextmoca.com"],"gitSource":{"type":"github","owner":"nextmoca","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"latestBuiltDeploymentHistoryId":"6adfb6bb2bd809a74de90453","collectionId":"55378fa7-b81c-4552-ba7d-361a12412dba","liveDeploymentHistoryId":"6adfb6bb2bd809a74de90453","schemaVersion":"v3"},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6adfb6bb2bd809a74de90453","clientVersion":"0.0.4044","searchFilterCounts":[{"language":"default","tag":"Documentation","count":18},{"language":"default","tag":"Running it in production","count":5},{"language":"default","tag":"How selection works","count":5},{"language":"default","tag":"API reference","count":4},{"language":"default","tag":"Get started","count":3},{"language":"default","tag":"Endpoints","count":3},{"language":"default","tag":"Billing","count":2},{"language":"default","tag":"Integrations","count":2},{"language":"default","tag":"Registry","count":2},{"language":"default","tag":"Overview","count":1}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"api-reference/selection/select-the-records-worth-sending-to-a-model","slug":"/api-reference/selection/select-the-records-worth-sending-to-a-model","pageMetadata":{"title":"Select the records worth sending to a model","description":"Send every record you are considering plus the task they must serve.\nNeedlepath returns the subset it selected, together with a rendered\nblock, per-record scores and reasons, and the token arithmetic.\n\n**Selection, not rewriting.** Nothing is paraphrased or summarised into\nnew prose and no model writes replacement text; an excerpt is built from\nthe record's own content. It is **not** guaranteed byte-identical to a\nspan of your input. See `SelectedRecord.excerpt`. If you need exact\nspans, join on `record_id` and use your own copy.\n\n**Stateless.** Records ride in on every request and nothing is persisted\nbetween calls, unless you have asked us in writing to capture your own\nrequests for a review (see Retention and trust). The same request under the same `operating_point` gets\nthe same answer, with two caveats before you assert on it in a test:\nthat guarantee is scoped to the request exactly as sent, so record order\nis part of it, and a record sent without an `id` comes back under a\nfreshly generated one. Send ids, and send a stable order.\n\n**A stand-down is a success.** When Needlepath cannot find evidence that a\nsmaller context covers the task, it stands down and returns your context\nessentially intact with `fallback_used = true`: on `np-2026-07-r2` as\n`outcome = stood_down` with an empty selection, and on `np-2026-08-r3`,\n`np-2026-08-r4`, `np-2026-10-r6`, `np-2026-10-r7` and `np-2026-10-r8` as `outcome = engaged` with every record\nreturned. Treat it as a normal 200 and send what you were going to send, and\ndo not treat a low `tokens_saved` as an error. Read `outcome` for this, never\n`gate`.\n\n**Fail open.** If this call times out, returns non-2xx, or returns an\nempty selection, send your original context unmodified. It is a binding\nrule for every integration, first-party or yours.\n","deprecated":null,"version":null,"openapi":"/api-reference/openapi.yaml post /v1/context/select","href":"/api-reference/selection/select-the-records-worth-sending-to-a-model","autogeneratedByOpenApi":true},"description":{"compiledSource":"\"use strict\";\nconst {Fragment: _Fragment, jsx: _jsx, jsxs: _jsxs} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n code: \"code\",\n p: \"p\",\n strong: \"strong\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsxs(_Fragment, {\n children: [_jsx(_components.p, {\n children: \"Send every record you are considering plus the task they must serve.\\nNeedlepath returns the subset it selected, together with a rendered\\nblock, per-record scores and reasons, and the token arithmetic.\"\n }), \"\\n\", _jsxs(_components.p, {\n children: [_jsx(_components.strong, {\n children: \"Selection, not rewriting.\"\n }), \" Nothing is paraphrased or summarised into\\nnew prose and no model writes replacement text; an excerpt is built from\\nthe record’s own content. It is \", _jsx(_components.strong, {\n children: \"not\"\n }), \" guaranteed byte-identical to a\\nspan of your input. See \", _jsx(_components.code, {\n children: \"SelectedRecord.excerpt\"\n }), \". If you need exact\\nspans, join on \", _jsx(_components.code, {\n children: \"record_id\"\n }), \" and use your own copy.\"]\n }), \"\\n\", _jsxs(_components.p, {\n children: [_jsx(_components.strong, {\n children: \"Stateless.\"\n }), \" Records ride in on every request and nothing is persisted\\nbetween calls, unless you have asked us in writing to capture your own\\nrequests for a review (see Retention and trust). The same request under the same \", _jsx(_components.code, {\n children: \"operating_point\"\n }), \" gets\\nthe same answer, with two caveats before you assert on it in a test:\\nthat guarantee is scoped to the request exactly as sent, so record order\\nis part of it, and a record sent without an \", _jsx(_components.code, {\n children: \"id\"\n }), \" comes back under a\\nfreshly generated one. Send ids, and send a stable order.\"]\n }), \"\\n\", _jsxs(_components.p, {\n children: [_jsx(_components.strong, {\n children: \"A stand-down is a success.\"\n }), \" When Needlepath cannot find evidence that a\\nsmaller context covers the task, it stands down and returns your context\\nessentially intact with \", _jsx(_components.code, {\n children: \"fallback_used = true\"\n }), \": on \", _jsx(_components.code, {\n children: \"np-2026-07-r2\"\n }), \" as\\n\", _jsx(_components.code, {\n children: \"outcome = stood_down\"\n }), \" with an empty selection, and on \", _jsx(_components.code, {\n children: \"np-2026-08-r3\"\n }), \",\\n\", _jsx(_components.code, {\n children: \"np-2026-08-r4\"\n }), \", \", _jsx(_components.code, {\n children: \"np-2026-10-r6\"\n }), \", \", _jsx(_components.code, {\n children: \"np-2026-10-r7\"\n }), \" and \", _jsx(_components.code, {\n children: \"np-2026-10-r8\"\n }), \" as \", _jsx(_components.code, {\n children: \"outcome = engaged\"\n }), \" with every record\\nreturned. Treat it as a normal 200 and send what you were going to send, and\\ndo not treat a low \", _jsx(_components.code, {\n children: \"tokens_saved\"\n }), \" as an error. Read \", _jsx(_components.code, {\n children: \"outcome\"\n }), \" for this, never\\n\", _jsx(_components.code, {\n children: \"gate\"\n }), \".\"]\n }), \"\\n\", _jsxs(_components.p, {\n children: [_jsx(_components.strong, {\n children: \"Fail open.\"\n }), \" If this call times out, returns non-2xx, or returns an\\nempty selection, send your original context unmodified. It is a binding\\nrule for every integration, first-party or yours.\"]\n })]\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){return _jsx(_Fragment,{})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Select the records worth sending to a model","description":"Send every record you are considering plus the task they must serve.\nNeedlepath returns the subset it selected, together with a rendered\nblock, per-record scores and reasons, and the token arithmetic.\n\n**Selection, not rewriting.** Nothing is paraphrased or summarised into\nnew prose and no model writes replacement text; an excerpt is built from\nthe record's own content. It is **not** guaranteed byte-identical to a\nspan of your input. See `SelectedRecord.excerpt`. If you need exact\nspans, join on `record_id` and use your own copy.\n\n**Stateless.** Records ride in on every request and nothing is persisted\nbetween calls, unless you have asked us in writing to capture your own\nrequests for a review (see Retention and trust). The same request under the same `operating_point` gets\nthe same answer, with two caveats before you assert on it in a test:\nthat guarantee is scoped to the request exactly as sent, so record order\nis part of it, and a record sent without an `id` comes back under a\nfreshly generated one. Send ids, and send a stable order.\n\n**A stand-down is a success.** When Needlepath cannot find evidence that a\nsmaller context covers the task, it stands down and returns your context\nessentially intact with `fallback_used = true`: on `np-2026-07-r2` as\n`outcome = stood_down` with an empty selection, and on `np-2026-08-r3`,\n`np-2026-08-r4`, `np-2026-10-r6`, `np-2026-10-r7` and `np-2026-10-r8` as `outcome = engaged` with every record\nreturned. Treat it as a normal 200 and send what you were going to send, and\ndo not treat a low `tokens_saved` as an error. Read `outcome` for this, never\n`gate`.\n\n**Fail open.** If this call times out, returns non-2xx, or returns an\nempty selection, send your original context unmodified. It is a binding\nrule for every integration, first-party or yours.\n","deprecated":null,"version":null,"openapi":"/api-reference/openapi.yaml post /v1/context/select","href":"/api-reference/selection/select-the-records-worth-sending-to-a-model","autogeneratedByOpenApi":true}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":[],"openApiReferenceData":{"operation":{"operationId":"selectContext","tags":["Selection"],"summary":"Select the records worth sending to a model","description":"Send every record you are considering plus the task they must serve.\nNeedlepath returns the subset it selected, together with a rendered\nblock, per-record scores and reasons, and the token arithmetic.\n\n**Selection, not rewriting.** Nothing is paraphrased or summarised into\nnew prose and no model writes replacement text; an excerpt is built from\nthe record's own content. It is **not** guaranteed byte-identical to a\nspan of your input. See `SelectedRecord.excerpt`. If you need exact\nspans, join on `record_id` and use your own copy.\n\n**Stateless.** Records ride in on every request and nothing is persisted\nbetween calls, unless you have asked us in writing to capture your own\nrequests for a review (see Retention and trust). The same request under the same `operating_point` gets\nthe same answer, with two caveats before you assert on it in a test:\nthat guarantee is scoped to the request exactly as sent, so record order\nis part of it, and a record sent without an `id` comes back under a\nfreshly generated one. Send ids, and send a stable order.\n\n**A stand-down is a success.** When Needlepath cannot find evidence that a\nsmaller context covers the task, it stands down and returns your context\nessentially intact with `fallback_used = true`: on `np-2026-07-r2` as\n`outcome = stood_down` with an empty selection, and on `np-2026-08-r3`,\n`np-2026-08-r4`, `np-2026-10-r6`, `np-2026-10-r7` and `np-2026-10-r8` as `outcome = engaged` with every record\nreturned. Treat it as a normal 200 and send what you were going to send, and\ndo not treat a low `tokens_saved` as an error. Read `outcome` for this, never\n`gate`.\n\n**Fail open.** If this call times out, returns non-2xx, or returns an\nempty selection, send your original context unmodified. It is a binding\nrule for every integration, first-party or yours.\n","x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl https://api.nextmoca.com/v1/context/select \\\n -H \"Authorization: Bearer $NEEDLEPATH_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"request_id\": \"req-2026-09-03-0001\",\n \"records\": [\n {\n \"id\": \"r-001\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(88231)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 88231, \\\"account\\\": \\\"acct_4415\\\", \\\"total_cents\\\": 432000, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"open\\\", \\\"issued\\\": \\\"2026-07-28\\\", \\\"due\\\": \\\"2026-08-27\\\", \\\"line_items\\\": [{\\\"sku\\\": \\\"NP-USAGE\\\", \\\"desc\\\": \\\"Metered input tokens, July\\\", \\\"qty\\\": 4800000, \\\"unit_price_cents\\\": 0.009}, {\\\"sku\\\": \\\"NP-SUPPORT\\\", \\\"desc\\\": \\\"Priority support\\\", \\\"qty\\\": 1, \\\"unit_price_cents\\\": 49900}]}\"\n },\n {\n \"id\": \"r-002\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_4415)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"name\\\": \\\"Meridian Analytics\\\", \\\"plan\\\": \\\"scale\\\", \\\"payment_method\\\": \\\"card_visa_6411\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2025-11-03\\\", \\\"owner\\\": \\\"dana@meridiananalytics.com\\\"}\"\n },\n {\n \"id\": \"r-003\",\n \"kind\": \"external_data\",\n \"title\": \"Data retention policy v3\",\n \"source\": \"handbook\",\n \"text\": \"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.\"\n },\n {\n \"id\": \"r-004\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 2\",\n \"source\": \"handbook\",\n \"text\": \"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\"\n },\n {\n \"id\": \"r-005\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 3 (exceptions)\",\n \"source\": \"handbook\",\n \"text\": \"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead'\\''s discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\"\n },\n {\n \"id\": \"r-006\",\n \"kind\": \"tool_result\",\n \"title\": \"get_usage(acct_4415, july)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"period\\\": \\\"2026-07\\\", \\\"input_tokens\\\": 4800000, \\\"requests\\\": 1210, \\\"stand_downs\\\": 34, \\\"charged_tokens\\\": 4646000}\"\n },\n {\n \"id\": \"r-007\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_9902)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5488\\\", \\\"subject\\\": \\\"API key rotation question\\\", \\\"opened\\\": \\\"2026-08-02\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-008\",\n \"kind\": \"user_input\",\n \"title\": null,\n \"source\": null,\n \"text\": \"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\"\n },\n {\n \"id\": \"r-009\",\n \"kind\": \"external_data\",\n \"title\": \"Credit policy v2\",\n \"source\": \"handbook\",\n \"text\": \"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner'\\''s written acknowledgement of the cause.\"\n },\n {\n \"id\": \"r-012\",\n \"kind\": \"tool_result\",\n \"title\": \"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"keys\\\": [{\\\"key_id\\\": \\\"np_key_a1\\\", \\\"requests\\\": 980, \\\"user_agent\\\": \\\"meridian-batch/2.1\\\", \\\"tokens\\\": 3100000}, {\\\"key_id\\\": \\\"np_key_b2\\\", \\\"requests\\\": 230, \\\"user_agent\\\": \\\"meridian-app/1.4\\\", \\\"tokens\\\": 1700000}], \\\"note\\\": \\\"np_key_a1 traffic stops 2026-07-19T14:02Z\\\"}\"\n },\n {\n \"id\": \"r-013\",\n \"kind\": \"external_data\",\n \"title\": \"Q2 headcount planning notes\",\n \"source\": \"internal-ops\",\n \"text\": \"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.\"\n },\n {\n \"id\": \"r-014\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(55102)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 55102, \\\"account\\\": \\\"acct_2210\\\", \\\"total_cents\\\": 18900, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"paid\\\", \\\"issued\\\": \\\"2026-07-15\\\", \\\"due\\\": \\\"2026-08-14\\\"}\"\n },\n {\n \"id\": \"r-015\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 marketing newsletter draft\",\n \"source\": \"marketing\",\n \"text\": \"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.\"\n },\n {\n \"id\": \"r-016\",\n \"kind\": \"external_data\",\n \"title\": \"Office move logistics\",\n \"source\": \"internal-ops\",\n \"text\": \"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.\"\n },\n {\n \"id\": \"r-017\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_4415)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5521\\\", \\\"subject\\\": \\\"July usage dispute\\\", \\\"opened\\\": \\\"2026-08-05\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-2\\\"}]}\"\n },\n {\n \"id\": \"r-018\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_2210)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5502\\\", \\\"subject\\\": \\\"Login issue after SSO migration\\\", \\\"opened\\\": \\\"2026-08-01\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-019\",\n \"kind\": \"external_data\",\n \"title\": \"Vacation and PTO policy\",\n \"source\": \"handbook\",\n \"text\": \"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.\"\n },\n {\n \"id\": \"r-020\",\n \"kind\": \"external_data\",\n \"title\": \"Runbook: rotating a compromised API key\",\n \"source\": \"ops-wiki\",\n \"text\": \"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.\"\n },\n {\n \"id\": \"r-021\",\n \"kind\": \"llm_response\",\n \"text\": \"I'\\''ve pulled up account acct_4415 and I'\\''m reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.\"\n },\n {\n \"id\": \"r-022\",\n \"kind\": \"external_data\",\n \"title\": \"Customer advisory board Q4 invite draft\",\n \"source\": \"marketing\",\n \"text\": \"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.\"\n },\n {\n \"id\": \"r-023\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_9902)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_9902\\\", \\\"name\\\": \\\"Colby Fixtures\\\", \\\"plan\\\": \\\"growth\\\", \\\"payment_method\\\": \\\"card_mc_2290\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2026-01-14\\\", \\\"owner\\\": \\\"ops@colbyfixtures.com\\\"}\"\n },\n {\n \"id\": \"r-026\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_5511)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5510\\\", \\\"subject\\\": \\\"Feature request: CSV export for usage analytics\\\", \\\"opened\\\": \\\"2026-08-03\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-027\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 all-hands agenda\",\n \"source\": \"internal-ops\",\n \"text\": \"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q\u0026A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.\"\n },\n {\n \"id\": \"r-029\",\n \"kind\": \"external_data\",\n \"title\": \"Marketing site refresh, visual only\",\n \"source\": \"marketing\",\n \"text\": \"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.\"\n },\n {\n \"id\": \"r-031\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_6630)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5477\\\", \\\"subject\\\": \\\"Onboarding walkthrough request\\\", \\\"opened\\\": \\\"2026-07-30\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-032\",\n \"kind\": \"external_data\",\n \"title\": \"On-call rotation for September\",\n \"source\": \"internal-ops\",\n \"text\": \"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.\"\n },\n {\n \"id\": \"r-033\",\n \"kind\": \"external_data\",\n \"title\": \"Partner co-marketing webinar recap\",\n \"source\": \"marketing\",\n \"text\": \"Tuesday'\\''s co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.\"\n },\n {\n \"id\": \"r-034\",\n \"kind\": \"external_data\",\n \"title\": \"Conference room booking policy\",\n \"source\": \"handbook\",\n \"text\": \"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.\"\n },\n {\n \"id\": \"r-035\",\n \"kind\": \"external_data\",\n \"title\": \"Blog editorial calendar, Q4\",\n \"source\": \"marketing\",\n \"text\": \"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.\"\n },\n {\n \"id\": \"r-036\",\n \"kind\": \"external_data\",\n \"title\": \"Kitchen and supplies restock schedule\",\n \"source\": \"internal-ops\",\n \"text\": \"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.\"\n }\n ],\n \"task\": {\n \"prompt\": \"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?\",\n \"tool_name\": \"resolve_billing_dispute\"\n },\n \"budget\": {\n \"max_context_tokens\": 900,\n \"operating_point\": \"np-2026-08-r4\"\n },\n \"render\": true,\n \"render_format\": \"plain\",\n \"return_per_record\": true\n}'"},{"lang":"python","label":"Python (requests)","source":"import os\nimport requests\n\npayload = {\n \"request_id\": \"req-2026-09-03-0001\",\n \"records\": [\n {\n \"id\": \"r-001\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(88231)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 88231, \\\"account\\\": \\\"acct_4415\\\", \\\"total_cents\\\": 432000, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"open\\\", \\\"issued\\\": \\\"2026-07-28\\\", \\\"due\\\": \\\"2026-08-27\\\", \\\"line_items\\\": [{\\\"sku\\\": \\\"NP-USAGE\\\", \\\"desc\\\": \\\"Metered input tokens, July\\\", \\\"qty\\\": 4800000, \\\"unit_price_cents\\\": 0.009}, {\\\"sku\\\": \\\"NP-SUPPORT\\\", \\\"desc\\\": \\\"Priority support\\\", \\\"qty\\\": 1, \\\"unit_price_cents\\\": 49900}]}\",\n },\n {\n \"id\": \"r-002\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_4415)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"name\\\": \\\"Meridian Analytics\\\", \\\"plan\\\": \\\"scale\\\", \\\"payment_method\\\": \\\"card_visa_6411\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2025-11-03\\\", \\\"owner\\\": \\\"dana@meridiananalytics.com\\\"}\",\n },\n {\n \"id\": \"r-003\",\n \"kind\": \"external_data\",\n \"title\": \"Data retention policy v3\",\n \"source\": \"handbook\",\n \"text\": \"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.\",\n },\n {\n \"id\": \"r-004\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 2\",\n \"source\": \"handbook\",\n \"text\": \"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\",\n },\n {\n \"id\": \"r-005\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 3 (exceptions)\",\n \"source\": \"handbook\",\n \"text\": \"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\",\n },\n {\n \"id\": \"r-006\",\n \"kind\": \"tool_result\",\n \"title\": \"get_usage(acct_4415, july)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"period\\\": \\\"2026-07\\\", \\\"input_tokens\\\": 4800000, \\\"requests\\\": 1210, \\\"stand_downs\\\": 34, \\\"charged_tokens\\\": 4646000}\",\n },\n {\n \"id\": \"r-007\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_9902)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5488\\\", \\\"subject\\\": \\\"API key rotation question\\\", \\\"opened\\\": \\\"2026-08-02\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\",\n },\n {\n \"id\": \"r-008\",\n \"kind\": \"user_input\",\n \"title\": None,\n \"source\": None,\n \"text\": \"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\",\n },\n {\n \"id\": \"r-009\",\n \"kind\": \"external_data\",\n \"title\": \"Credit policy v2\",\n \"source\": \"handbook\",\n \"text\": \"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.\",\n },\n {\n \"id\": \"r-012\",\n \"kind\": \"tool_result\",\n \"title\": \"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"keys\\\": [{\\\"key_id\\\": \\\"np_key_a1\\\", \\\"requests\\\": 980, \\\"user_agent\\\": \\\"meridian-batch/2.1\\\", \\\"tokens\\\": 3100000}, {\\\"key_id\\\": \\\"np_key_b2\\\", \\\"requests\\\": 230, \\\"user_agent\\\": \\\"meridian-app/1.4\\\", \\\"tokens\\\": 1700000}], \\\"note\\\": \\\"np_key_a1 traffic stops 2026-07-19T14:02Z\\\"}\",\n },\n {\n \"id\": \"r-013\",\n \"kind\": \"external_data\",\n \"title\": \"Q2 headcount planning notes\",\n \"source\": \"internal-ops\",\n \"text\": \"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.\",\n },\n {\n \"id\": \"r-014\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(55102)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 55102, \\\"account\\\": \\\"acct_2210\\\", \\\"total_cents\\\": 18900, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"paid\\\", \\\"issued\\\": \\\"2026-07-15\\\", \\\"due\\\": \\\"2026-08-14\\\"}\",\n },\n {\n \"id\": \"r-015\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 marketing newsletter draft\",\n \"source\": \"marketing\",\n \"text\": \"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.\",\n },\n {\n \"id\": \"r-016\",\n \"kind\": \"external_data\",\n \"title\": \"Office move logistics\",\n \"source\": \"internal-ops\",\n \"text\": \"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.\",\n },\n {\n \"id\": \"r-017\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_4415)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5521\\\", \\\"subject\\\": \\\"July usage dispute\\\", \\\"opened\\\": \\\"2026-08-05\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-2\\\"}]}\",\n },\n {\n \"id\": \"r-018\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_2210)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5502\\\", \\\"subject\\\": \\\"Login issue after SSO migration\\\", \\\"opened\\\": \\\"2026-08-01\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\",\n },\n {\n \"id\": \"r-019\",\n \"kind\": \"external_data\",\n \"title\": \"Vacation and PTO policy\",\n \"source\": \"handbook\",\n \"text\": \"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.\",\n },\n {\n \"id\": \"r-020\",\n \"kind\": \"external_data\",\n \"title\": \"Runbook: rotating a compromised API key\",\n \"source\": \"ops-wiki\",\n \"text\": \"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.\",\n },\n {\n \"id\": \"r-021\",\n \"kind\": \"llm_response\",\n \"text\": \"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.\",\n },\n {\n \"id\": \"r-022\",\n \"kind\": \"external_data\",\n \"title\": \"Customer advisory board Q4 invite draft\",\n \"source\": \"marketing\",\n \"text\": \"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.\",\n },\n {\n \"id\": \"r-023\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_9902)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_9902\\\", \\\"name\\\": \\\"Colby Fixtures\\\", \\\"plan\\\": \\\"growth\\\", \\\"payment_method\\\": \\\"card_mc_2290\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2026-01-14\\\", \\\"owner\\\": \\\"ops@colbyfixtures.com\\\"}\",\n },\n {\n \"id\": \"r-026\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_5511)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5510\\\", \\\"subject\\\": \\\"Feature request: CSV export for usage analytics\\\", \\\"opened\\\": \\\"2026-08-03\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\",\n },\n {\n \"id\": \"r-027\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 all-hands agenda\",\n \"source\": \"internal-ops\",\n \"text\": \"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q\u0026A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.\",\n },\n {\n \"id\": \"r-029\",\n \"kind\": \"external_data\",\n \"title\": \"Marketing site refresh, visual only\",\n \"source\": \"marketing\",\n \"text\": \"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.\",\n },\n {\n \"id\": \"r-031\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_6630)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5477\\\", \\\"subject\\\": \\\"Onboarding walkthrough request\\\", \\\"opened\\\": \\\"2026-07-30\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\",\n },\n {\n \"id\": \"r-032\",\n \"kind\": \"external_data\",\n \"title\": \"On-call rotation for September\",\n \"source\": \"internal-ops\",\n \"text\": \"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.\",\n },\n {\n \"id\": \"r-033\",\n \"kind\": \"external_data\",\n \"title\": \"Partner co-marketing webinar recap\",\n \"source\": \"marketing\",\n \"text\": \"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.\",\n },\n {\n \"id\": \"r-034\",\n \"kind\": \"external_data\",\n \"title\": \"Conference room booking policy\",\n \"source\": \"handbook\",\n \"text\": \"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.\",\n },\n {\n \"id\": \"r-035\",\n \"kind\": \"external_data\",\n \"title\": \"Blog editorial calendar, Q4\",\n \"source\": \"marketing\",\n \"text\": \"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.\",\n },\n {\n \"id\": \"r-036\",\n \"kind\": \"external_data\",\n \"title\": \"Kitchen and supplies restock schedule\",\n \"source\": \"internal-ops\",\n \"text\": \"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.\",\n },\n ],\n \"task\": {\n \"prompt\": \"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?\",\n \"tool_name\": \"resolve_billing_dispute\",\n },\n \"budget\": {\n \"max_context_tokens\": 900,\n \"operating_point\": \"np-2026-08-r4\",\n },\n \"render\": True,\n \"render_format\": \"plain\",\n \"return_per_record\": True,\n}\n\nr = requests.post(\n \"https://api.nextmoca.com/v1/context/select\",\n headers={\"Authorization\": f\"Bearer {os.environ['NEEDLEPATH_API_KEY']}\"},\n json=payload,\n timeout=10,\n)\nr.raise_for_status()\nresult = r.json()\nprint(result[\"records_selected\"], \"selected,\", result[\"tokens_saved\"], \"tokens saved\")"},{"lang":"typescript","label":"TypeScript (fetch)","source":"const payload = {\n \"request_id\": \"req-2026-09-03-0001\",\n \"records\": [\n {\n \"id\": \"r-001\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(88231)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 88231, \\\"account\\\": \\\"acct_4415\\\", \\\"total_cents\\\": 432000, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"open\\\", \\\"issued\\\": \\\"2026-07-28\\\", \\\"due\\\": \\\"2026-08-27\\\", \\\"line_items\\\": [{\\\"sku\\\": \\\"NP-USAGE\\\", \\\"desc\\\": \\\"Metered input tokens, July\\\", \\\"qty\\\": 4800000, \\\"unit_price_cents\\\": 0.009}, {\\\"sku\\\": \\\"NP-SUPPORT\\\", \\\"desc\\\": \\\"Priority support\\\", \\\"qty\\\": 1, \\\"unit_price_cents\\\": 49900}]}\"\n },\n {\n \"id\": \"r-002\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_4415)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"name\\\": \\\"Meridian Analytics\\\", \\\"plan\\\": \\\"scale\\\", \\\"payment_method\\\": \\\"card_visa_6411\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2025-11-03\\\", \\\"owner\\\": \\\"dana@meridiananalytics.com\\\"}\"\n },\n {\n \"id\": \"r-003\",\n \"kind\": \"external_data\",\n \"title\": \"Data retention policy v3\",\n \"source\": \"handbook\",\n \"text\": \"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.\"\n },\n {\n \"id\": \"r-004\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 2\",\n \"source\": \"handbook\",\n \"text\": \"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\"\n },\n {\n \"id\": \"r-005\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 3 (exceptions)\",\n \"source\": \"handbook\",\n \"text\": \"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\"\n },\n {\n \"id\": \"r-006\",\n \"kind\": \"tool_result\",\n \"title\": \"get_usage(acct_4415, july)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"period\\\": \\\"2026-07\\\", \\\"input_tokens\\\": 4800000, \\\"requests\\\": 1210, \\\"stand_downs\\\": 34, \\\"charged_tokens\\\": 4646000}\"\n },\n {\n \"id\": \"r-007\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_9902)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5488\\\", \\\"subject\\\": \\\"API key rotation question\\\", \\\"opened\\\": \\\"2026-08-02\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-008\",\n \"kind\": \"user_input\",\n \"title\": null,\n \"source\": null,\n \"text\": \"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\"\n },\n {\n \"id\": \"r-009\",\n \"kind\": \"external_data\",\n \"title\": \"Credit policy v2\",\n \"source\": \"handbook\",\n \"text\": \"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.\"\n },\n {\n \"id\": \"r-012\",\n \"kind\": \"tool_result\",\n \"title\": \"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"keys\\\": [{\\\"key_id\\\": \\\"np_key_a1\\\", \\\"requests\\\": 980, \\\"user_agent\\\": \\\"meridian-batch/2.1\\\", \\\"tokens\\\": 3100000}, {\\\"key_id\\\": \\\"np_key_b2\\\", \\\"requests\\\": 230, \\\"user_agent\\\": \\\"meridian-app/1.4\\\", \\\"tokens\\\": 1700000}], \\\"note\\\": \\\"np_key_a1 traffic stops 2026-07-19T14:02Z\\\"}\"\n },\n {\n \"id\": \"r-013\",\n \"kind\": \"external_data\",\n \"title\": \"Q2 headcount planning notes\",\n \"source\": \"internal-ops\",\n \"text\": \"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.\"\n },\n {\n \"id\": \"r-014\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(55102)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 55102, \\\"account\\\": \\\"acct_2210\\\", \\\"total_cents\\\": 18900, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"paid\\\", \\\"issued\\\": \\\"2026-07-15\\\", \\\"due\\\": \\\"2026-08-14\\\"}\"\n },\n {\n \"id\": \"r-015\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 marketing newsletter draft\",\n \"source\": \"marketing\",\n \"text\": \"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.\"\n },\n {\n \"id\": \"r-016\",\n \"kind\": \"external_data\",\n \"title\": \"Office move logistics\",\n \"source\": \"internal-ops\",\n \"text\": \"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.\"\n },\n {\n \"id\": \"r-017\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_4415)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5521\\\", \\\"subject\\\": \\\"July usage dispute\\\", \\\"opened\\\": \\\"2026-08-05\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-2\\\"}]}\"\n },\n {\n \"id\": \"r-018\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_2210)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5502\\\", \\\"subject\\\": \\\"Login issue after SSO migration\\\", \\\"opened\\\": \\\"2026-08-01\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-019\",\n \"kind\": \"external_data\",\n \"title\": \"Vacation and PTO policy\",\n \"source\": \"handbook\",\n \"text\": \"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.\"\n },\n {\n \"id\": \"r-020\",\n \"kind\": \"external_data\",\n \"title\": \"Runbook: rotating a compromised API key\",\n \"source\": \"ops-wiki\",\n \"text\": \"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.\"\n },\n {\n \"id\": \"r-021\",\n \"kind\": \"llm_response\",\n \"text\": \"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.\"\n },\n {\n \"id\": \"r-022\",\n \"kind\": \"external_data\",\n \"title\": \"Customer advisory board Q4 invite draft\",\n \"source\": \"marketing\",\n \"text\": \"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.\"\n },\n {\n \"id\": \"r-023\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_9902)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_9902\\\", \\\"name\\\": \\\"Colby Fixtures\\\", \\\"plan\\\": \\\"growth\\\", \\\"payment_method\\\": \\\"card_mc_2290\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2026-01-14\\\", \\\"owner\\\": \\\"ops@colbyfixtures.com\\\"}\"\n },\n {\n \"id\": \"r-026\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_5511)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5510\\\", \\\"subject\\\": \\\"Feature request: CSV export for usage analytics\\\", \\\"opened\\\": \\\"2026-08-03\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-027\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 all-hands agenda\",\n \"source\": \"internal-ops\",\n \"text\": \"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q\u0026A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.\"\n },\n {\n \"id\": \"r-029\",\n \"kind\": \"external_data\",\n \"title\": \"Marketing site refresh, visual only\",\n \"source\": \"marketing\",\n \"text\": \"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.\"\n },\n {\n \"id\": \"r-031\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_6630)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5477\\\", \\\"subject\\\": \\\"Onboarding walkthrough request\\\", \\\"opened\\\": \\\"2026-07-30\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-032\",\n \"kind\": \"external_data\",\n \"title\": \"On-call rotation for September\",\n \"source\": \"internal-ops\",\n \"text\": \"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.\"\n },\n {\n \"id\": \"r-033\",\n \"kind\": \"external_data\",\n \"title\": \"Partner co-marketing webinar recap\",\n \"source\": \"marketing\",\n \"text\": \"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.\"\n },\n {\n \"id\": \"r-034\",\n \"kind\": \"external_data\",\n \"title\": \"Conference room booking policy\",\n \"source\": \"handbook\",\n \"text\": \"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.\"\n },\n {\n \"id\": \"r-035\",\n \"kind\": \"external_data\",\n \"title\": \"Blog editorial calendar, Q4\",\n \"source\": \"marketing\",\n \"text\": \"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.\"\n },\n {\n \"id\": \"r-036\",\n \"kind\": \"external_data\",\n \"title\": \"Kitchen and supplies restock schedule\",\n \"source\": \"internal-ops\",\n \"text\": \"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.\"\n }\n ],\n \"task\": {\n \"prompt\": \"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?\",\n \"tool_name\": \"resolve_billing_dispute\"\n },\n \"budget\": {\n \"max_context_tokens\": 900,\n \"operating_point\": \"np-2026-08-r4\"\n },\n \"render\": true,\n \"render_format\": \"plain\",\n \"return_per_record\": true\n};\n\nconst res = await fetch(\"https://api.nextmoca.com/v1/context/select\", {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${process.env.NEEDLEPATH_API_KEY}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n});\nconst result = await res.json();\nconsole.log(result.records_selected, \"selected,\", result.tokens_saved, \"tokens saved\");"}],"security":["65cfa12f-220d-445b-b6a3-dd3043674305"],"requestBody":"16eb6493-9e35-4c8d-9c94-bebf18245b99","responses":{"200":"f75d7b68-8ae4-4c70-af37-4aa16418236d","400":"5290fec6-a230-4e8a-8e68-44395f902966","401":"8aba5f28-297c-44be-9e10-9ec703667b97","402":"3ad080d0-aed5-4c65-a8dc-f92719fe4f2d","403":"7f90e9fc-11fa-469d-b299-e017c3c21672","413":"bcf0f676-0152-4651-833c-d00ea630112d","429":"c22eaff2-d95b-4d87-87bf-2cfdd9203a25","500":"045bce8b-c42d-4760-9f9f-cf2509e42d47"},"method":"post","type":"path","servers":["8823b6b3-5c44-4637-a982-da3bf24a7ba8"],"path":"/v1/context/select","baseUrlOptions":["https://api.nextmoca.com"],"title":"Select the records worth sending to a model","codeSamples":[{"label":"cURL","lang":"curl","source":"curl https://api.nextmoca.com/v1/context/select \\\n -H \"Authorization: Bearer $NEEDLEPATH_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"request_id\": \"req-2026-09-03-0001\",\n \"records\": [\n {\n \"id\": \"r-001\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(88231)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 88231, \\\"account\\\": \\\"acct_4415\\\", \\\"total_cents\\\": 432000, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"open\\\", \\\"issued\\\": \\\"2026-07-28\\\", \\\"due\\\": \\\"2026-08-27\\\", \\\"line_items\\\": [{\\\"sku\\\": \\\"NP-USAGE\\\", \\\"desc\\\": \\\"Metered input tokens, July\\\", \\\"qty\\\": 4800000, \\\"unit_price_cents\\\": 0.009}, {\\\"sku\\\": \\\"NP-SUPPORT\\\", \\\"desc\\\": \\\"Priority support\\\", \\\"qty\\\": 1, \\\"unit_price_cents\\\": 49900}]}\"\n },\n {\n \"id\": \"r-002\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_4415)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"name\\\": \\\"Meridian Analytics\\\", \\\"plan\\\": \\\"scale\\\", \\\"payment_method\\\": \\\"card_visa_6411\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2025-11-03\\\", \\\"owner\\\": \\\"dana@meridiananalytics.com\\\"}\"\n },\n {\n \"id\": \"r-003\",\n \"kind\": \"external_data\",\n \"title\": \"Data retention policy v3\",\n \"source\": \"handbook\",\n \"text\": \"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.\"\n },\n {\n \"id\": \"r-004\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 2\",\n \"source\": \"handbook\",\n \"text\": \"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\"\n },\n {\n \"id\": \"r-005\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 3 (exceptions)\",\n \"source\": \"handbook\",\n \"text\": \"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead'\\''s discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\"\n },\n {\n \"id\": \"r-006\",\n \"kind\": \"tool_result\",\n \"title\": \"get_usage(acct_4415, july)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"period\\\": \\\"2026-07\\\", \\\"input_tokens\\\": 4800000, \\\"requests\\\": 1210, \\\"stand_downs\\\": 34, \\\"charged_tokens\\\": 4646000}\"\n },\n {\n \"id\": \"r-007\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_9902)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5488\\\", \\\"subject\\\": \\\"API key rotation question\\\", \\\"opened\\\": \\\"2026-08-02\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-008\",\n \"kind\": \"user_input\",\n \"title\": null,\n \"source\": null,\n \"text\": \"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\"\n },\n {\n \"id\": \"r-009\",\n \"kind\": \"external_data\",\n \"title\": \"Credit policy v2\",\n \"source\": \"handbook\",\n \"text\": \"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner'\\''s written acknowledgement of the cause.\"\n },\n {\n \"id\": \"r-012\",\n \"kind\": \"tool_result\",\n \"title\": \"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"keys\\\": [{\\\"key_id\\\": \\\"np_key_a1\\\", \\\"requests\\\": 980, \\\"user_agent\\\": \\\"meridian-batch/2.1\\\", \\\"tokens\\\": 3100000}, {\\\"key_id\\\": \\\"np_key_b2\\\", \\\"requests\\\": 230, \\\"user_agent\\\": \\\"meridian-app/1.4\\\", \\\"tokens\\\": 1700000}], \\\"note\\\": \\\"np_key_a1 traffic stops 2026-07-19T14:02Z\\\"}\"\n },\n {\n \"id\": \"r-013\",\n \"kind\": \"external_data\",\n \"title\": \"Q2 headcount planning notes\",\n \"source\": \"internal-ops\",\n \"text\": \"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.\"\n },\n {\n \"id\": \"r-014\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(55102)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 55102, \\\"account\\\": \\\"acct_2210\\\", \\\"total_cents\\\": 18900, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"paid\\\", \\\"issued\\\": \\\"2026-07-15\\\", \\\"due\\\": \\\"2026-08-14\\\"}\"\n },\n {\n \"id\": \"r-015\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 marketing newsletter draft\",\n \"source\": \"marketing\",\n \"text\": \"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.\"\n },\n {\n \"id\": \"r-016\",\n \"kind\": \"external_data\",\n \"title\": \"Office move logistics\",\n \"source\": \"internal-ops\",\n \"text\": \"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.\"\n },\n {\n \"id\": \"r-017\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_4415)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5521\\\", \\\"subject\\\": \\\"July usage dispute\\\", \\\"opened\\\": \\\"2026-08-05\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-2\\\"}]}\"\n },\n {\n \"id\": \"r-018\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_2210)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5502\\\", \\\"subject\\\": \\\"Login issue after SSO migration\\\", \\\"opened\\\": \\\"2026-08-01\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-019\",\n \"kind\": \"external_data\",\n \"title\": \"Vacation and PTO policy\",\n \"source\": \"handbook\",\n \"text\": \"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.\"\n },\n {\n \"id\": \"r-020\",\n \"kind\": \"external_data\",\n \"title\": \"Runbook: rotating a compromised API key\",\n \"source\": \"ops-wiki\",\n \"text\": \"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.\"\n },\n {\n \"id\": \"r-021\",\n \"kind\": \"llm_response\",\n \"text\": \"I'\\''ve pulled up account acct_4415 and I'\\''m reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.\"\n },\n {\n \"id\": \"r-022\",\n \"kind\": \"external_data\",\n \"title\": \"Customer advisory board Q4 invite draft\",\n \"source\": \"marketing\",\n \"text\": \"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.\"\n },\n {\n \"id\": \"r-023\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_9902)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_9902\\\", \\\"name\\\": \\\"Colby Fixtures\\\", \\\"plan\\\": \\\"growth\\\", \\\"payment_method\\\": \\\"card_mc_2290\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2026-01-14\\\", \\\"owner\\\": \\\"ops@colbyfixtures.com\\\"}\"\n },\n {\n \"id\": \"r-026\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_5511)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5510\\\", \\\"subject\\\": \\\"Feature request: CSV export for usage analytics\\\", \\\"opened\\\": \\\"2026-08-03\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-027\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 all-hands agenda\",\n \"source\": \"internal-ops\",\n \"text\": \"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q\u0026A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.\"\n },\n {\n \"id\": \"r-029\",\n \"kind\": \"external_data\",\n \"title\": \"Marketing site refresh, visual only\",\n \"source\": \"marketing\",\n \"text\": \"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.\"\n },\n {\n \"id\": \"r-031\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_6630)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5477\\\", \\\"subject\\\": \\\"Onboarding walkthrough request\\\", \\\"opened\\\": \\\"2026-07-30\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-032\",\n \"kind\": \"external_data\",\n \"title\": \"On-call rotation for September\",\n \"source\": \"internal-ops\",\n \"text\": \"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.\"\n },\n {\n \"id\": \"r-033\",\n \"kind\": \"external_data\",\n \"title\": \"Partner co-marketing webinar recap\",\n \"source\": \"marketing\",\n \"text\": \"Tuesday'\\''s co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.\"\n },\n {\n \"id\": \"r-034\",\n \"kind\": \"external_data\",\n \"title\": \"Conference room booking policy\",\n \"source\": \"handbook\",\n \"text\": \"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.\"\n },\n {\n \"id\": \"r-035\",\n \"kind\": \"external_data\",\n \"title\": \"Blog editorial calendar, Q4\",\n \"source\": \"marketing\",\n \"text\": \"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.\"\n },\n {\n \"id\": \"r-036\",\n \"kind\": \"external_data\",\n \"title\": \"Kitchen and supplies restock schedule\",\n \"source\": \"internal-ops\",\n \"text\": \"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.\"\n }\n ],\n \"task\": {\n \"prompt\": \"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?\",\n \"tool_name\": \"resolve_billing_dispute\"\n },\n \"budget\": {\n \"max_context_tokens\": 900,\n \"operating_point\": \"np-2026-08-r4\"\n },\n \"render\": true,\n \"render_format\": \"plain\",\n \"return_per_record\": true\n}'"},{"label":"Python (requests)","lang":"python","source":"import os\nimport requests\n\npayload = {\n \"request_id\": \"req-2026-09-03-0001\",\n \"records\": [\n {\n \"id\": \"r-001\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(88231)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 88231, \\\"account\\\": \\\"acct_4415\\\", \\\"total_cents\\\": 432000, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"open\\\", \\\"issued\\\": \\\"2026-07-28\\\", \\\"due\\\": \\\"2026-08-27\\\", \\\"line_items\\\": [{\\\"sku\\\": \\\"NP-USAGE\\\", \\\"desc\\\": \\\"Metered input tokens, July\\\", \\\"qty\\\": 4800000, \\\"unit_price_cents\\\": 0.009}, {\\\"sku\\\": \\\"NP-SUPPORT\\\", \\\"desc\\\": \\\"Priority support\\\", \\\"qty\\\": 1, \\\"unit_price_cents\\\": 49900}]}\",\n },\n {\n \"id\": \"r-002\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_4415)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"name\\\": \\\"Meridian Analytics\\\", \\\"plan\\\": \\\"scale\\\", \\\"payment_method\\\": \\\"card_visa_6411\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2025-11-03\\\", \\\"owner\\\": \\\"dana@meridiananalytics.com\\\"}\",\n },\n {\n \"id\": \"r-003\",\n \"kind\": \"external_data\",\n \"title\": \"Data retention policy v3\",\n \"source\": \"handbook\",\n \"text\": \"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.\",\n },\n {\n \"id\": \"r-004\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 2\",\n \"source\": \"handbook\",\n \"text\": \"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\",\n },\n {\n \"id\": \"r-005\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 3 (exceptions)\",\n \"source\": \"handbook\",\n \"text\": \"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\",\n },\n {\n \"id\": \"r-006\",\n \"kind\": \"tool_result\",\n \"title\": \"get_usage(acct_4415, july)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"period\\\": \\\"2026-07\\\", \\\"input_tokens\\\": 4800000, \\\"requests\\\": 1210, \\\"stand_downs\\\": 34, \\\"charged_tokens\\\": 4646000}\",\n },\n {\n \"id\": \"r-007\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_9902)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5488\\\", \\\"subject\\\": \\\"API key rotation question\\\", \\\"opened\\\": \\\"2026-08-02\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\",\n },\n {\n \"id\": \"r-008\",\n \"kind\": \"user_input\",\n \"title\": None,\n \"source\": None,\n \"text\": \"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\",\n },\n {\n \"id\": \"r-009\",\n \"kind\": \"external_data\",\n \"title\": \"Credit policy v2\",\n \"source\": \"handbook\",\n \"text\": \"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.\",\n },\n {\n \"id\": \"r-012\",\n \"kind\": \"tool_result\",\n \"title\": \"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"keys\\\": [{\\\"key_id\\\": \\\"np_key_a1\\\", \\\"requests\\\": 980, \\\"user_agent\\\": \\\"meridian-batch/2.1\\\", \\\"tokens\\\": 3100000}, {\\\"key_id\\\": \\\"np_key_b2\\\", \\\"requests\\\": 230, \\\"user_agent\\\": \\\"meridian-app/1.4\\\", \\\"tokens\\\": 1700000}], \\\"note\\\": \\\"np_key_a1 traffic stops 2026-07-19T14:02Z\\\"}\",\n },\n {\n \"id\": \"r-013\",\n \"kind\": \"external_data\",\n \"title\": \"Q2 headcount planning notes\",\n \"source\": \"internal-ops\",\n \"text\": \"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.\",\n },\n {\n \"id\": \"r-014\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(55102)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 55102, \\\"account\\\": \\\"acct_2210\\\", \\\"total_cents\\\": 18900, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"paid\\\", \\\"issued\\\": \\\"2026-07-15\\\", \\\"due\\\": \\\"2026-08-14\\\"}\",\n },\n {\n \"id\": \"r-015\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 marketing newsletter draft\",\n \"source\": \"marketing\",\n \"text\": \"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.\",\n },\n {\n \"id\": \"r-016\",\n \"kind\": \"external_data\",\n \"title\": \"Office move logistics\",\n \"source\": \"internal-ops\",\n \"text\": \"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.\",\n },\n {\n \"id\": \"r-017\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_4415)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5521\\\", \\\"subject\\\": \\\"July usage dispute\\\", \\\"opened\\\": \\\"2026-08-05\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-2\\\"}]}\",\n },\n {\n \"id\": \"r-018\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_2210)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5502\\\", \\\"subject\\\": \\\"Login issue after SSO migration\\\", \\\"opened\\\": \\\"2026-08-01\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\",\n },\n {\n \"id\": \"r-019\",\n \"kind\": \"external_data\",\n \"title\": \"Vacation and PTO policy\",\n \"source\": \"handbook\",\n \"text\": \"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.\",\n },\n {\n \"id\": \"r-020\",\n \"kind\": \"external_data\",\n \"title\": \"Runbook: rotating a compromised API key\",\n \"source\": \"ops-wiki\",\n \"text\": \"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.\",\n },\n {\n \"id\": \"r-021\",\n \"kind\": \"llm_response\",\n \"text\": \"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.\",\n },\n {\n \"id\": \"r-022\",\n \"kind\": \"external_data\",\n \"title\": \"Customer advisory board Q4 invite draft\",\n \"source\": \"marketing\",\n \"text\": \"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.\",\n },\n {\n \"id\": \"r-023\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_9902)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_9902\\\", \\\"name\\\": \\\"Colby Fixtures\\\", \\\"plan\\\": \\\"growth\\\", \\\"payment_method\\\": \\\"card_mc_2290\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2026-01-14\\\", \\\"owner\\\": \\\"ops@colbyfixtures.com\\\"}\",\n },\n {\n \"id\": \"r-026\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_5511)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5510\\\", \\\"subject\\\": \\\"Feature request: CSV export for usage analytics\\\", \\\"opened\\\": \\\"2026-08-03\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\",\n },\n {\n \"id\": \"r-027\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 all-hands agenda\",\n \"source\": \"internal-ops\",\n \"text\": \"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q\u0026A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.\",\n },\n {\n \"id\": \"r-029\",\n \"kind\": \"external_data\",\n \"title\": \"Marketing site refresh, visual only\",\n \"source\": \"marketing\",\n \"text\": \"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.\",\n },\n {\n \"id\": \"r-031\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_6630)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5477\\\", \\\"subject\\\": \\\"Onboarding walkthrough request\\\", \\\"opened\\\": \\\"2026-07-30\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\",\n },\n {\n \"id\": \"r-032\",\n \"kind\": \"external_data\",\n \"title\": \"On-call rotation for September\",\n \"source\": \"internal-ops\",\n \"text\": \"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.\",\n },\n {\n \"id\": \"r-033\",\n \"kind\": \"external_data\",\n \"title\": \"Partner co-marketing webinar recap\",\n \"source\": \"marketing\",\n \"text\": \"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.\",\n },\n {\n \"id\": \"r-034\",\n \"kind\": \"external_data\",\n \"title\": \"Conference room booking policy\",\n \"source\": \"handbook\",\n \"text\": \"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.\",\n },\n {\n \"id\": \"r-035\",\n \"kind\": \"external_data\",\n \"title\": \"Blog editorial calendar, Q4\",\n \"source\": \"marketing\",\n \"text\": \"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.\",\n },\n {\n \"id\": \"r-036\",\n \"kind\": \"external_data\",\n \"title\": \"Kitchen and supplies restock schedule\",\n \"source\": \"internal-ops\",\n \"text\": \"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.\",\n },\n ],\n \"task\": {\n \"prompt\": \"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?\",\n \"tool_name\": \"resolve_billing_dispute\",\n },\n \"budget\": {\n \"max_context_tokens\": 900,\n \"operating_point\": \"np-2026-08-r4\",\n },\n \"render\": True,\n \"render_format\": \"plain\",\n \"return_per_record\": True,\n}\n\nr = requests.post(\n \"https://api.nextmoca.com/v1/context/select\",\n headers={\"Authorization\": f\"Bearer {os.environ['NEEDLEPATH_API_KEY']}\"},\n json=payload,\n timeout=10,\n)\nr.raise_for_status()\nresult = r.json()\nprint(result[\"records_selected\"], \"selected,\", result[\"tokens_saved\"], \"tokens saved\")"},{"label":"TypeScript (fetch)","lang":"typescript","source":"const payload = {\n \"request_id\": \"req-2026-09-03-0001\",\n \"records\": [\n {\n \"id\": \"r-001\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(88231)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 88231, \\\"account\\\": \\\"acct_4415\\\", \\\"total_cents\\\": 432000, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"open\\\", \\\"issued\\\": \\\"2026-07-28\\\", \\\"due\\\": \\\"2026-08-27\\\", \\\"line_items\\\": [{\\\"sku\\\": \\\"NP-USAGE\\\", \\\"desc\\\": \\\"Metered input tokens, July\\\", \\\"qty\\\": 4800000, \\\"unit_price_cents\\\": 0.009}, {\\\"sku\\\": \\\"NP-SUPPORT\\\", \\\"desc\\\": \\\"Priority support\\\", \\\"qty\\\": 1, \\\"unit_price_cents\\\": 49900}]}\"\n },\n {\n \"id\": \"r-002\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_4415)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"name\\\": \\\"Meridian Analytics\\\", \\\"plan\\\": \\\"scale\\\", \\\"payment_method\\\": \\\"card_visa_6411\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2025-11-03\\\", \\\"owner\\\": \\\"dana@meridiananalytics.com\\\"}\"\n },\n {\n \"id\": \"r-003\",\n \"kind\": \"external_data\",\n \"title\": \"Data retention policy v3\",\n \"source\": \"handbook\",\n \"text\": \"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.\"\n },\n {\n \"id\": \"r-004\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 2\",\n \"source\": \"handbook\",\n \"text\": \"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\"\n },\n {\n \"id\": \"r-005\",\n \"kind\": \"external_data\",\n \"title\": \"Refund policy v4, section 3 (exceptions)\",\n \"source\": \"handbook\",\n \"text\": \"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\"\n },\n {\n \"id\": \"r-006\",\n \"kind\": \"tool_result\",\n \"title\": \"get_usage(acct_4415, july)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_4415\\\", \\\"period\\\": \\\"2026-07\\\", \\\"input_tokens\\\": 4800000, \\\"requests\\\": 1210, \\\"stand_downs\\\": 34, \\\"charged_tokens\\\": 4646000}\"\n },\n {\n \"id\": \"r-007\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_9902)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5488\\\", \\\"subject\\\": \\\"API key rotation question\\\", \\\"opened\\\": \\\"2026-08-02\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-008\",\n \"kind\": \"user_input\",\n \"title\": null,\n \"source\": null,\n \"text\": \"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\"\n },\n {\n \"id\": \"r-009\",\n \"kind\": \"external_data\",\n \"title\": \"Credit policy v2\",\n \"source\": \"handbook\",\n \"text\": \"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.\"\n },\n {\n \"id\": \"r-012\",\n \"kind\": \"tool_result\",\n \"title\": \"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)\",\n \"source\": \"metering-api\",\n \"text\": \"{\\\"keys\\\": [{\\\"key_id\\\": \\\"np_key_a1\\\", \\\"requests\\\": 980, \\\"user_agent\\\": \\\"meridian-batch/2.1\\\", \\\"tokens\\\": 3100000}, {\\\"key_id\\\": \\\"np_key_b2\\\", \\\"requests\\\": 230, \\\"user_agent\\\": \\\"meridian-app/1.4\\\", \\\"tokens\\\": 1700000}], \\\"note\\\": \\\"np_key_a1 traffic stops 2026-07-19T14:02Z\\\"}\"\n },\n {\n \"id\": \"r-013\",\n \"kind\": \"external_data\",\n \"title\": \"Q2 headcount planning notes\",\n \"source\": \"internal-ops\",\n \"text\": \"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.\"\n },\n {\n \"id\": \"r-014\",\n \"kind\": \"tool_result\",\n \"title\": \"get_invoice(55102)\",\n \"source\": \"billing-api\",\n \"text\": \"{\\\"invoice_id\\\": 55102, \\\"account\\\": \\\"acct_2210\\\", \\\"total_cents\\\": 18900, \\\"currency\\\": \\\"usd\\\", \\\"status\\\": \\\"paid\\\", \\\"issued\\\": \\\"2026-07-15\\\", \\\"due\\\": \\\"2026-08-14\\\"}\"\n },\n {\n \"id\": \"r-015\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 marketing newsletter draft\",\n \"source\": \"marketing\",\n \"text\": \"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.\"\n },\n {\n \"id\": \"r-016\",\n \"kind\": \"external_data\",\n \"title\": \"Office move logistics\",\n \"source\": \"internal-ops\",\n \"text\": \"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.\"\n },\n {\n \"id\": \"r-017\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_4415)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5521\\\", \\\"subject\\\": \\\"July usage dispute\\\", \\\"opened\\\": \\\"2026-08-05\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-2\\\"}]}\"\n },\n {\n \"id\": \"r-018\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_2210)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5502\\\", \\\"subject\\\": \\\"Login issue after SSO migration\\\", \\\"opened\\\": \\\"2026-08-01\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-019\",\n \"kind\": \"external_data\",\n \"title\": \"Vacation and PTO policy\",\n \"source\": \"handbook\",\n \"text\": \"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.\"\n },\n {\n \"id\": \"r-020\",\n \"kind\": \"external_data\",\n \"title\": \"Runbook: rotating a compromised API key\",\n \"source\": \"ops-wiki\",\n \"text\": \"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.\"\n },\n {\n \"id\": \"r-021\",\n \"kind\": \"llm_response\",\n \"text\": \"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.\"\n },\n {\n \"id\": \"r-022\",\n \"kind\": \"external_data\",\n \"title\": \"Customer advisory board Q4 invite draft\",\n \"source\": \"marketing\",\n \"text\": \"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.\"\n },\n {\n \"id\": \"r-023\",\n \"kind\": \"tool_result\",\n \"title\": \"get_account(acct_9902)\",\n \"source\": \"crm-api\",\n \"text\": \"{\\\"account_id\\\": \\\"acct_9902\\\", \\\"name\\\": \\\"Colby Fixtures\\\", \\\"plan\\\": \\\"growth\\\", \\\"payment_method\\\": \\\"card_mc_2290\\\", \\\"delinquent\\\": false, \\\"since\\\": \\\"2026-01-14\\\", \\\"owner\\\": \\\"ops@colbyfixtures.com\\\"}\"\n },\n {\n \"id\": \"r-026\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_5511)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5510\\\", \\\"subject\\\": \\\"Feature request: CSV export for usage analytics\\\", \\\"opened\\\": \\\"2026-08-03\\\", \\\"status\\\": \\\"open\\\", \\\"assignee\\\": \\\"support-lead-1\\\"}]}\"\n },\n {\n \"id\": \"r-027\",\n \"kind\": \"external_data\",\n \"title\": \"Q3 all-hands agenda\",\n \"source\": \"internal-ops\",\n \"text\": \"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q\u0026A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.\"\n },\n {\n \"id\": \"r-029\",\n \"kind\": \"external_data\",\n \"title\": \"Marketing site refresh, visual only\",\n \"source\": \"marketing\",\n \"text\": \"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.\"\n },\n {\n \"id\": \"r-031\",\n \"kind\": \"tool_result\",\n \"title\": \"get_open_tickets(acct_6630)\",\n \"source\": \"support-api\",\n \"text\": \"{\\\"tickets\\\": [{\\\"id\\\": \\\"T-5477\\\", \\\"subject\\\": \\\"Onboarding walkthrough request\\\", \\\"opened\\\": \\\"2026-07-30\\\", \\\"status\\\": \\\"closed\\\", \\\"assignee\\\": \\\"support-lead-3\\\"}]}\"\n },\n {\n \"id\": \"r-032\",\n \"kind\": \"external_data\",\n \"title\": \"On-call rotation for September\",\n \"source\": \"internal-ops\",\n \"text\": \"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.\"\n },\n {\n \"id\": \"r-033\",\n \"kind\": \"external_data\",\n \"title\": \"Partner co-marketing webinar recap\",\n \"source\": \"marketing\",\n \"text\": \"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.\"\n },\n {\n \"id\": \"r-034\",\n \"kind\": \"external_data\",\n \"title\": \"Conference room booking policy\",\n \"source\": \"handbook\",\n \"text\": \"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.\"\n },\n {\n \"id\": \"r-035\",\n \"kind\": \"external_data\",\n \"title\": \"Blog editorial calendar, Q4\",\n \"source\": \"marketing\",\n \"text\": \"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.\"\n },\n {\n \"id\": \"r-036\",\n \"kind\": \"external_data\",\n \"title\": \"Kitchen and supplies restock schedule\",\n \"source\": \"internal-ops\",\n \"text\": \"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.\"\n }\n ],\n \"task\": {\n \"prompt\": \"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?\",\n \"tool_name\": \"resolve_billing_dispute\"\n },\n \"budget\": {\n \"max_context_tokens\": 900,\n \"operating_point\": \"np-2026-08-r4\"\n },\n \"render\": true,\n \"render_format\": \"plain\",\n \"return_per_record\": true\n};\n\nconst res = await fetch(\"https://api.nextmoca.com/v1/context/select\", {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${process.env.NEEDLEPATH_API_KEY}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n});\nconst result = await res.json();\nconsole.log(result.records_selected, \"selected,\", result.tokens_saved, \"tokens saved\");"}],"requiredOnlyExamples":false,"requestExampleType":"codeSamples","responseExampleType":"generated","prefillPlaygroundWithExample":true,"prefillPlaygroundExamples":[{"body.oneOf.0.records.items.0.text":"{\"invoice_id\": 88231, \"account\": \"acct_4415\", \"total_cents\": 432000, \"currency\": \"usd\", \"status\": \"open\", \"issued\": \"2026-07-28\", \"due\": \"2026-08-27\", \"line_items\": [{\"sku\": \"NP-USAGE\", \"desc\": \"Metered input tokens, July\", \"qty\": 4800000, \"unit_price_cents\": 0.009}, {\"sku\": \"NP-SUPPORT\", \"desc\": \"Priority support\", \"qty\": 1, \"unit_price_cents\": 49900}]}","body.oneOf.0.records.items.0.kind":"tool_result","body.oneOf.0.records.items.0.id.oneOf.0":"r-001","body.oneOf.0.records.items.0.source.oneOf.0":"billing-api","body.oneOf.0.records.items.0.title.oneOf.0":"get_invoice(88231)","body.oneOf.0.records.items.1.text":"{\"account_id\": \"acct_4415\", \"name\": \"Meridian Analytics\", \"plan\": \"scale\", \"payment_method\": \"card_visa_6411\", \"delinquent\": false, \"since\": \"2025-11-03\", \"owner\": \"dana@meridiananalytics.com\"}","body.oneOf.0.records.items.1.kind":"tool_result","body.oneOf.0.records.items.1.id.oneOf.0":"r-002","body.oneOf.0.records.items.1.source.oneOf.0":"crm-api","body.oneOf.0.records.items.1.title.oneOf.0":"get_account(acct_4415)","body.oneOf.0.records.items.2.text":"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility.","body.oneOf.0.records.items.2.kind":"external_data","body.oneOf.0.records.items.2.id.oneOf.0":"r-003","body.oneOf.0.records.items.2.source.oneOf.0":"handbook","body.oneOf.0.records.items.2.title.oneOf.0":"Data retention policy v3","body.oneOf.0.records.items.3.text":"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.","body.oneOf.0.records.items.3.kind":"external_data","body.oneOf.0.records.items.3.id.oneOf.0":"r-004","body.oneOf.0.records.items.3.source.oneOf.0":"handbook","body.oneOf.0.records.items.3.title.oneOf.0":"Refund policy v4, section 2","body.oneOf.0.records.items.4.text":"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.","body.oneOf.0.records.items.4.kind":"external_data","body.oneOf.0.records.items.4.id.oneOf.0":"r-005","body.oneOf.0.records.items.4.source.oneOf.0":"handbook","body.oneOf.0.records.items.4.title.oneOf.0":"Refund policy v4, section 3 (exceptions)","body.oneOf.0.records.items.5.text":"{\"account_id\": \"acct_4415\", \"period\": \"2026-07\", \"input_tokens\": 4800000, \"requests\": 1210, \"stand_downs\": 34, \"charged_tokens\": 4646000}","body.oneOf.0.records.items.5.kind":"tool_result","body.oneOf.0.records.items.5.id.oneOf.0":"r-006","body.oneOf.0.records.items.5.source.oneOf.0":"metering-api","body.oneOf.0.records.items.5.title.oneOf.0":"get_usage(acct_4415, july)","body.oneOf.0.records.items.6.text":"{\"tickets\": [{\"id\": \"T-5488\", \"subject\": \"API key rotation question\", \"opened\": \"2026-08-02\", \"status\": \"closed\", \"assignee\": \"support-lead-1\"}]}","body.oneOf.0.records.items.6.kind":"tool_result","body.oneOf.0.records.items.6.id.oneOf.0":"r-007","body.oneOf.0.records.items.6.source.oneOf.0":"support-api","body.oneOf.0.records.items.6.title.oneOf.0":"get_open_tickets(acct_9902)","body.oneOf.0.records.items.7.text":"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?","body.oneOf.0.records.items.7.kind":"user_input","body.oneOf.0.records.items.7.id.oneOf.0":"r-008","body.oneOf.0.records.items.8.text":"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause.","body.oneOf.0.records.items.8.kind":"external_data","body.oneOf.0.records.items.8.id.oneOf.0":"r-009","body.oneOf.0.records.items.8.source.oneOf.0":"handbook","body.oneOf.0.records.items.8.title.oneOf.0":"Credit policy v2","body.oneOf.0.records.items.9.text":"{\"keys\": [{\"key_id\": \"np_key_a1\", \"requests\": 980, \"user_agent\": \"meridian-batch/2.1\", \"tokens\": 3100000}, {\"key_id\": \"np_key_b2\", \"requests\": 230, \"user_agent\": \"meridian-app/1.4\", \"tokens\": 1700000}], \"note\": \"np_key_a1 traffic stops 2026-07-19T14:02Z\"}","body.oneOf.0.records.items.9.kind":"tool_result","body.oneOf.0.records.items.9.id.oneOf.0":"r-012","body.oneOf.0.records.items.9.source.oneOf.0":"metering-api","body.oneOf.0.records.items.9.title.oneOf.0":"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)","body.oneOf.0.records.items.10.text":"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3.","body.oneOf.0.records.items.10.kind":"external_data","body.oneOf.0.records.items.10.id.oneOf.0":"r-013","body.oneOf.0.records.items.10.source.oneOf.0":"internal-ops","body.oneOf.0.records.items.10.title.oneOf.0":"Q2 headcount planning notes","body.oneOf.0.records.items.11.text":"{\"invoice_id\": 55102, \"account\": \"acct_2210\", \"total_cents\": 18900, \"currency\": \"usd\", \"status\": \"paid\", \"issued\": \"2026-07-15\", \"due\": \"2026-08-14\"}","body.oneOf.0.records.items.11.kind":"tool_result","body.oneOf.0.records.items.11.id.oneOf.0":"r-014","body.oneOf.0.records.items.11.source.oneOf.0":"billing-api","body.oneOf.0.records.items.11.title.oneOf.0":"get_invoice(55102)","body.oneOf.0.records.items.12.text":"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September.","body.oneOf.0.records.items.12.kind":"external_data","body.oneOf.0.records.items.12.id.oneOf.0":"r-015","body.oneOf.0.records.items.12.source.oneOf.0":"marketing","body.oneOf.0.records.items.12.title.oneOf.0":"Q3 marketing newsletter draft","body.oneOf.0.records.items.13.text":"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes.","body.oneOf.0.records.items.13.kind":"external_data","body.oneOf.0.records.items.13.id.oneOf.0":"r-016","body.oneOf.0.records.items.13.source.oneOf.0":"internal-ops","body.oneOf.0.records.items.13.title.oneOf.0":"Office move logistics","body.oneOf.0.records.items.14.text":"{\"tickets\": [{\"id\": \"T-5521\", \"subject\": \"July usage dispute\", \"opened\": \"2026-08-05\", \"status\": \"open\", \"assignee\": \"support-lead-2\"}]}","body.oneOf.0.records.items.14.kind":"tool_result","body.oneOf.0.records.items.14.id.oneOf.0":"r-017","body.oneOf.0.records.items.14.source.oneOf.0":"support-api","body.oneOf.0.records.items.14.title.oneOf.0":"get_open_tickets(acct_4415)","body.oneOf.0.records.items.15.text":"{\"tickets\": [{\"id\": \"T-5502\", \"subject\": \"Login issue after SSO migration\", \"opened\": \"2026-08-01\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}","body.oneOf.0.records.items.15.kind":"tool_result","body.oneOf.0.records.items.15.id.oneOf.0":"r-018","body.oneOf.0.records.items.15.source.oneOf.0":"support-api","body.oneOf.0.records.items.15.title.oneOf.0":"get_open_tickets(acct_2210)","body.oneOf.0.records.items.16.text":"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect.","body.oneOf.0.records.items.16.kind":"external_data","body.oneOf.0.records.items.16.id.oneOf.0":"r-019","body.oneOf.0.records.items.16.source.oneOf.0":"handbook","body.oneOf.0.records.items.16.title.oneOf.0":"Vacation and PTO policy","body.oneOf.0.records.items.17.text":"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes.","body.oneOf.0.records.items.17.kind":"external_data","body.oneOf.0.records.items.17.id.oneOf.0":"r-020","body.oneOf.0.records.items.17.source.oneOf.0":"ops-wiki","body.oneOf.0.records.items.17.title.oneOf.0":"Runbook: rotating a compromised API key","body.oneOf.0.records.items.18.text":"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.","body.oneOf.0.records.items.18.kind":"llm_response","body.oneOf.0.records.items.18.id.oneOf.0":"r-021","body.oneOf.0.records.items.19.text":"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support.","body.oneOf.0.records.items.19.kind":"external_data","body.oneOf.0.records.items.19.id.oneOf.0":"r-022","body.oneOf.0.records.items.19.source.oneOf.0":"marketing","body.oneOf.0.records.items.19.title.oneOf.0":"Customer advisory board Q4 invite draft","body.oneOf.0.records.items.20.text":"{\"account_id\": \"acct_9902\", \"name\": \"Colby Fixtures\", \"plan\": \"growth\", \"payment_method\": \"card_mc_2290\", \"delinquent\": false, \"since\": \"2026-01-14\", \"owner\": \"ops@colbyfixtures.com\"}","body.oneOf.0.records.items.20.kind":"tool_result","body.oneOf.0.records.items.20.id.oneOf.0":"r-023","body.oneOf.0.records.items.20.source.oneOf.0":"crm-api","body.oneOf.0.records.items.20.title.oneOf.0":"get_account(acct_9902)","body.oneOf.0.records.items.21.text":"{\"tickets\": [{\"id\": \"T-5510\", \"subject\": \"Feature request: CSV export for usage analytics\", \"opened\": \"2026-08-03\", \"status\": \"open\", \"assignee\": \"support-lead-1\"}]}","body.oneOf.0.records.items.21.kind":"tool_result","body.oneOf.0.records.items.21.id.oneOf.0":"r-026","body.oneOf.0.records.items.21.source.oneOf.0":"support-api","body.oneOf.0.records.items.21.title.oneOf.0":"get_open_tickets(acct_5511)","body.oneOf.0.records.items.22.text":"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q\u0026A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live.","body.oneOf.0.records.items.22.kind":"external_data","body.oneOf.0.records.items.22.id.oneOf.0":"r-027","body.oneOf.0.records.items.22.source.oneOf.0":"internal-ops","body.oneOf.0.records.items.22.title.oneOf.0":"Q3 all-hands agenda","body.oneOf.0.records.items.23.text":"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only.","body.oneOf.0.records.items.23.kind":"external_data","body.oneOf.0.records.items.23.id.oneOf.0":"r-029","body.oneOf.0.records.items.23.source.oneOf.0":"marketing","body.oneOf.0.records.items.23.title.oneOf.0":"Marketing site refresh, visual only","body.oneOf.0.records.items.24.text":"{\"tickets\": [{\"id\": \"T-5477\", \"subject\": \"Onboarding walkthrough request\", \"opened\": \"2026-07-30\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}","body.oneOf.0.records.items.24.kind":"tool_result","body.oneOf.0.records.items.24.id.oneOf.0":"r-031","body.oneOf.0.records.items.24.source.oneOf.0":"support-api","body.oneOf.0.records.items.24.title.oneOf.0":"get_open_tickets(acct_6630)","body.oneOf.0.records.items.25.text":"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead.","body.oneOf.0.records.items.25.kind":"external_data","body.oneOf.0.records.items.25.id.oneOf.0":"r-032","body.oneOf.0.records.items.25.source.oneOf.0":"internal-ops","body.oneOf.0.records.items.25.title.oneOf.0":"On-call rotation for September","body.oneOf.0.records.items.26.text":"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week.","body.oneOf.0.records.items.26.kind":"external_data","body.oneOf.0.records.items.26.id.oneOf.0":"r-033","body.oneOf.0.records.items.26.source.oneOf.0":"marketing","body.oneOf.0.records.items.26.title.oneOf.0":"Partner co-marketing webinar recap","body.oneOf.0.records.items.27.text":"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing.","body.oneOf.0.records.items.27.kind":"external_data","body.oneOf.0.records.items.27.id.oneOf.0":"r-034","body.oneOf.0.records.items.27.source.oneOf.0":"handbook","body.oneOf.0.records.items.27.title.oneOf.0":"Conference room booking policy","body.oneOf.0.records.items.28.text":"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication.","body.oneOf.0.records.items.28.kind":"external_data","body.oneOf.0.records.items.28.id.oneOf.0":"r-035","body.oneOf.0.records.items.28.source.oneOf.0":"marketing","body.oneOf.0.records.items.28.title.oneOf.0":"Blog editorial calendar, Q4","body.oneOf.0.records.items.29.text":"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week.","body.oneOf.0.records.items.29.kind":"external_data","body.oneOf.0.records.items.29.id.oneOf.0":"r-036","body.oneOf.0.records.items.29.source.oneOf.0":"internal-ops","body.oneOf.0.records.items.29.title.oneOf.0":"Kitchen and supplies restock schedule","body.oneOf.0.task.prompt":"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?","body.oneOf.0.task.tool_name.oneOf.0":"resolve_billing_dispute","body.oneOf.0.budget.max_context_tokens":900,"body.oneOf.0.budget.operating_point.oneOf.0":"np-2026-08-r4","body.oneOf.0.request_id":"req-2026-09-03-0001","body.oneOf.0.render":true,"body.oneOf.0.render_format":"plain","body.oneOf.0.return_per_record":true},{"body.oneOf.0.records.items.0.text":"{\"invoice_id\": 4471, \"total_cents\": 128400, \"status\": \"open\"}","body.oneOf.0.records.items.0.kind":"tool_result","body.oneOf.0.records.items.0.id.oneOf.0":"r-812","body.oneOf.0.records.items.0.source.oneOf.0":"billing-api","body.oneOf.0.records.items.0.title.oneOf.0":"get_invoice(4471)","body.oneOf.0.records.items.0.importance":0,"body.oneOf.0.records.items.1.text":"Refunds are issued to the original payment method within 10 business days.","body.oneOf.0.records.items.1.kind":"external_data","body.oneOf.0.records.items.1.id.oneOf.0":"r-813","body.oneOf.0.records.items.1.source.oneOf.0":"handbook","body.oneOf.0.records.items.1.title.oneOf.0":"Refund policy v4","body.oneOf.0.records.items.2.text":"I have pulled up the account. One moment.","body.oneOf.0.records.items.2.kind":"llm_response","body.oneOf.0.records.items.2.id.oneOf.0":"r-814","body.oneOf.0.task.prompt":"Can this invoice still be refunded?","body.oneOf.0.task.tool_name.oneOf.0":"answer_customer","body.oneOf.0.budget.max_context_tokens":4000,"body.oneOf.0.budget.operating_point.oneOf.0":"np-2026-08-r4","body.oneOf.0.request_id":"req-2026-08-01-0001","body.oneOf.0.render":true,"body.oneOf.0.render_format":"plain","body.oneOf.0.return_per_record":true},{"body.oneOf.1.text":"Customer dana@meridiananalytics.com disputes the July invoice: roughly a third of the usage came from a runaway integration on their side, shut down on July 19. They ask for a refund or credit for the excess.\n\nRefund policy: refunds are issued only for platform-caused overcharges verified against receipts. Service credits differ: for customer-caused overuse, credits up to 25% of the disputed amount may be granted once per account per year, applied to the next invoice.\n\nThe Austin office move completes August 15. Badge access transfers automatically, desk assignments are posted on the intranet, the fourth-floor kitchen closes during the transition, visitor parking moves to the north garage, and commuter benefits need updating by August 10 for anyone using transit passes. Facilities will run tours on Friday.\n\nThe Q3 marketing case-study series features five accounts and is scheduled for September publication; drafts are with legal review and the design team is preparing pull quotes, hero images, and a landing page refresh to accompany the launch announcement.\n\nThe support Slack workspace migrates to a new domain next Tuesday. Existing channels and history carry over automatically; only bookmarked links need updating.\n\nQuarterly OKR review is scheduled for the last week of the quarter, with each team submitting a one-page summary two business days ahead.\n\nThe status page gained a subscribe-by-email option this release, alongside the existing RSS feed and webhook.\n\nConference room booking now supports recurring holds up to eight weeks out, previously capped at two.","body.oneOf.1.task.prompt":"What portion of the disputed usage was customer-caused, and does that qualify it for a refund or a service credit?","body.oneOf.1.budget.max_context_tokens":400}]},"dependencies":{"parameters":{},"requestBody":{"required":true,"description":"Either `ContextRequest` (typed `records[]`) or\n`SimpleTextContextRequest` (free-form `text`); never both. Maximum\nbody size is **6 MB**, the AWS Lambda synchronous payload cap. API\nGateway rejects an oversized body before the service is invoked, so\nguard it client-side rather than relying on a readable error.\n","content":{"application/json":{"schema":{"oneOf":[{"type":"object","required":["records","task","budget"],"example":{"request_id":"req-2026-09-03-0001","records":[{"id":"r-001","kind":"tool_result","title":"get_invoice(88231)","source":"billing-api","text":"{\"invoice_id\": 88231, \"account\": \"acct_4415\", \"total_cents\": 432000, \"currency\": \"usd\", \"status\": \"open\", \"issued\": \"2026-07-28\", \"due\": \"2026-08-27\", \"line_items\": [{\"sku\": \"NP-USAGE\", \"desc\": \"Metered input tokens, July\", \"qty\": 4800000, \"unit_price_cents\": 0.009}, {\"sku\": \"NP-SUPPORT\", \"desc\": \"Priority support\", \"qty\": 1, \"unit_price_cents\": 49900}]}"},{"id":"r-002","kind":"tool_result","title":"get_account(acct_4415)","source":"crm-api","text":"{\"account_id\": \"acct_4415\", \"name\": \"Meridian Analytics\", \"plan\": \"scale\", \"payment_method\": \"card_visa_6411\", \"delinquent\": false, \"since\": \"2025-11-03\", \"owner\": \"dana@meridiananalytics.com\"}"},{"id":"r-003","kind":"external_data","title":"Data retention policy v3","source":"handbook","text":"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility."},{"id":"r-004","kind":"external_data","title":"Refund policy v4, section 2","source":"handbook","text":"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible."},{"id":"r-005","kind":"external_data","title":"Refund policy v4, section 3 (exceptions)","source":"handbook","text":"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered."},{"id":"r-006","kind":"tool_result","title":"get_usage(acct_4415, july)","source":"metering-api","text":"{\"account_id\": \"acct_4415\", \"period\": \"2026-07\", \"input_tokens\": 4800000, \"requests\": 1210, \"stand_downs\": 34, \"charged_tokens\": 4646000}"},{"id":"r-007","kind":"tool_result","title":"get_open_tickets(acct_9902)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5488\", \"subject\": \"API key rotation question\", \"opened\": \"2026-08-02\", \"status\": \"closed\", \"assignee\": \"support-lead-1\"}]}"},{"id":"r-008","kind":"user_input","title":null,"source":null,"text":"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?"},{"id":"r-009","kind":"external_data","title":"Credit policy v2","source":"handbook","text":"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause."},{"id":"r-012","kind":"tool_result","title":"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)","source":"metering-api","text":"{\"keys\": [{\"key_id\": \"np_key_a1\", \"requests\": 980, \"user_agent\": \"meridian-batch/2.1\", \"tokens\": 3100000}, {\"key_id\": \"np_key_b2\", \"requests\": 230, \"user_agent\": \"meridian-app/1.4\", \"tokens\": 1700000}], \"note\": \"np_key_a1 traffic stops 2026-07-19T14:02Z\"}"},{"id":"r-013","kind":"external_data","title":"Q2 headcount planning notes","source":"internal-ops","text":"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3."},{"id":"r-014","kind":"tool_result","title":"get_invoice(55102)","source":"billing-api","text":"{\"invoice_id\": 55102, \"account\": \"acct_2210\", \"total_cents\": 18900, \"currency\": \"usd\", \"status\": \"paid\", \"issued\": \"2026-07-15\", \"due\": \"2026-08-14\"}"},{"id":"r-015","kind":"external_data","title":"Q3 marketing newsletter draft","source":"marketing","text":"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September."},{"id":"r-016","kind":"external_data","title":"Office move logistics","source":"internal-ops","text":"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes."},{"id":"r-017","kind":"tool_result","title":"get_open_tickets(acct_4415)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5521\", \"subject\": \"July usage dispute\", \"opened\": \"2026-08-05\", \"status\": \"open\", \"assignee\": \"support-lead-2\"}]}"},{"id":"r-018","kind":"tool_result","title":"get_open_tickets(acct_2210)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5502\", \"subject\": \"Login issue after SSO migration\", \"opened\": \"2026-08-01\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}"},{"id":"r-019","kind":"external_data","title":"Vacation and PTO policy","source":"handbook","text":"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect."},{"id":"r-020","kind":"external_data","title":"Runbook: rotating a compromised API key","source":"ops-wiki","text":"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes."},{"id":"r-021","kind":"llm_response","text":"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown."},{"id":"r-022","kind":"external_data","title":"Customer advisory board Q4 invite draft","source":"marketing","text":"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support."},{"id":"r-023","kind":"tool_result","title":"get_account(acct_9902)","source":"crm-api","text":"{\"account_id\": \"acct_9902\", \"name\": \"Colby Fixtures\", \"plan\": \"growth\", \"payment_method\": \"card_mc_2290\", \"delinquent\": false, \"since\": \"2026-01-14\", \"owner\": \"ops@colbyfixtures.com\"}"},{"id":"r-026","kind":"tool_result","title":"get_open_tickets(acct_5511)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5510\", \"subject\": \"Feature request: CSV export for usage analytics\", \"opened\": \"2026-08-03\", \"status\": \"open\", \"assignee\": \"support-lead-1\"}]}"},{"id":"r-027","kind":"external_data","title":"Q3 all-hands agenda","source":"internal-ops","text":"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q\u0026A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live."},{"id":"r-029","kind":"external_data","title":"Marketing site refresh, visual only","source":"marketing","text":"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only."},{"id":"r-031","kind":"tool_result","title":"get_open_tickets(acct_6630)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5477\", \"subject\": \"Onboarding walkthrough request\", \"opened\": \"2026-07-30\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}"},{"id":"r-032","kind":"external_data","title":"On-call rotation for September","source":"internal-ops","text":"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead."},{"id":"r-033","kind":"external_data","title":"Partner co-marketing webinar recap","source":"marketing","text":"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week."},{"id":"r-034","kind":"external_data","title":"Conference room booking policy","source":"handbook","text":"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing."},{"id":"r-035","kind":"external_data","title":"Blog editorial calendar, Q4","source":"marketing","text":"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication."},{"id":"r-036","kind":"external_data","title":"Kitchen and supplies restock schedule","source":"internal-ops","text":"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week."}],"task":{"prompt":"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?","tool_name":"resolve_billing_dispute"},"budget":{"max_context_tokens":900,"operating_point":"np-2026-08-r4"},"render":true,"render_format":"plain","return_per_record":true},"properties":{"records":{"type":"array","description":"The records Needlepath may keep, drop or excerpt. An empty array is\naccepted and yields an empty selection. Record order breaks score\nties, and record count is capped per request alongside the token\nceiling. See *Limits* and *Records and tasks*.\n","items":{"type":"object","required":["text"],"description":"One unit of state. `text` is the only required field; everything else is\na signal that improves selection. Token counts are computed server-side\nand there is no field to supply one into.\n","properties":{"text":{"type":"string","description":"The content. Selection keeps or excerpts it and never rewrites it\ninto new prose. See `SelectedRecord.excerpt` for the exact guarantee,\nwhich is narrower than byte-identity.\n","examples":["{\"invoice_id\": 4471, \"total_cents\": 128400, \"status\": \"open\"}"],"example":"{\"invoice_id\": 88231, \"account\": \"acct_4415\", \"total_cents\": 432000, \"currency\": \"usd\", \"status\": \"open\", \"issued\": \"2026-07-28\", \"due\": \"2026-08-27\", \"line_items\": [{\"sku\": \"NP-USAGE\", \"desc\": \"Metered input tokens, July\", \"qty\": 4800000, \"unit_price_cents\": 0.009}, {\"sku\": \"NP-SUPPORT\", \"desc\": \"Priority support\", \"qty\": 1, \"unit_price_cents\": 49900}]}","isRequired":true,"uniqueKey":"oneOf.0.records.items.[INDEX].text","typeLabel":"string"},"kind":{"type":"string","default":"external_data","enum":["user_input","llm_response","tool_call","tool_result","external_data","error","artifact","tool_schema"],"description":"The record's role. This is the published set and a value outside it\nis rejected. Roles carry different selection priors, so labelling\nhonestly is worth more than labelling everything `external_data`.\n`tool_schema` is reserved for tool and function schemas and is\nselected like any other record on the operating points served. See\n*Records and tasks*.\n","example":"tool_result","uniqueKey":"oneOf.0.records.items.[INDEX].kind","typeLabel":"enum\u003cstring>"},"id":{"oneOf":[{"type":"string","description":"Your id for this record, echoed as `selected[].record_id`. Without\none a server-generated id is returned and it matches nothing you\nhold.\n","example":"r-001","uniqueKey":"oneOf.0.records.items.[INDEX].id.oneOf.0","typeLabel":"string"},{"type":"null","description":"Your id for this record, echoed as `selected[].record_id`. Without\none a server-generated id is returned and it matches nothing you\nhold.\n","example":"r-001","uniqueKey":"oneOf.0.records.items.[INDEX].id.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.records.items.[INDEX].id","typeLabel":"string | null"},"source":{"oneOf":[{"type":"string","description":"Where the record came from. Echoed on the selection.","example":"billing-api","uniqueKey":"oneOf.0.records.items.[INDEX].source.oneOf.0","typeLabel":"string"},{"type":"null","description":"Where the record came from. Echoed on the selection.","example":"billing-api","uniqueKey":"oneOf.0.records.items.[INDEX].source.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.records.items.[INDEX].source","typeLabel":"string | null"},"source_kind":{"oneOf":[{"type":"string","enum":["system","developer","user","tool","web","email","file","memory","retrieval","unknown",null],"description":"The record's provenance class. Read only by security screening, for its\nreceipt (`format_metrics.security_source_kinds`); it never changes what is\nscreened, no value exempts a record, and it does not affect selection.\nOmitted, the receipt reports `unknown`. See *Records and tasks*.\n","example":"tool","uniqueKey":"oneOf.0.records.items.[INDEX].source_kind.oneOf.0","typeLabel":"enum\u003cstring>"},{"type":"null","enum":["system","developer","user","tool","web","email","file","memory","retrieval","unknown",null],"description":"The record's provenance class. Read only by security screening, for its\nreceipt (`format_metrics.security_source_kinds`); it never changes what is\nscreened, no value exempts a record, and it does not affect selection.\nOmitted, the receipt reports `unknown`. See *Records and tasks*.\n","example":"tool","uniqueKey":"oneOf.0.records.items.[INDEX].source_kind.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.records.items.[INDEX].source_kind","typeLabel":"enum\u003cstring> | null"},"title":{"oneOf":[{"type":"string","description":"A short human label. Echoed on the selection, and **metered**. See *How to recompute your own bill*.","example":"get_invoice(88231)","uniqueKey":"oneOf.0.records.items.[INDEX].title.oneOf.0","typeLabel":"string"},{"type":"null","description":"A short human label. Echoed on the selection, and **metered**. See *How to recompute your own bill*.","example":"get_invoice(88231)","uniqueKey":"oneOf.0.records.items.[INDEX].title.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.records.items.[INDEX].title","typeLabel":"string | null"},"step_id":{"oneOf":[{"type":"string","description":"The step in your workflow that produced this record. Used for recency and drift signals.","uniqueKey":"oneOf.0.records.items.[INDEX].step_id.oneOf.0","typeLabel":"string"},{"type":"null","description":"The step in your workflow that produced this record. Used for recency and drift signals.","uniqueKey":"oneOf.0.records.items.[INDEX].step_id.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.records.items.[INDEX].step_id","typeLabel":"string | null"},"importance":{"type":"number","format":"double","default":0,"description":"Your own relevance prior. A hint, not an override: a high\n`importance` does not pin a record into the selection.\n","uniqueKey":"oneOf.0.records.items.[INDEX].importance","typeLabel":"number\u003cdouble>"},"keywords":{"type":"array","items":{"type":"string","uniqueKey":"oneOf.0.records.items.[INDEX].keywords.items.[INDEX]","typeLabel":"string"},"default":[],"description":"Indexing hints. **Not metered**, and bounded by the published size cap. See *Limits*.","uniqueKey":"oneOf.0.records.items.[INDEX].keywords","typeLabel":"string[]"},"tags":{"type":"array","items":{"type":"string","uniqueKey":"oneOf.0.records.items.[INDEX].tags.items.[INDEX]","typeLabel":"string"},"default":[],"description":"Indexing hints. **Not metered**, and bounded by the published size cap.","uniqueKey":"oneOf.0.records.items.[INDEX].tags","typeLabel":"string[]"},"attributes":{"type":"object","additionalProperties":true,"default":{},"description":"Opaque per-kind passthrough, folded into the text the engine infers\nentities, keywords and tags from. **Not metered**, and bounded by the\npublished size cap. Put content in `text`, not here. See *Records and\ntasks*.\n","uniqueKey":"oneOf.0.records.items.[INDEX].attributes","typeLabel":"object"}},"uniqueKey":"oneOf.0.records.items.[INDEX]","typeLabel":"object"},"example":[{"id":"r-001","kind":"tool_result","title":"get_invoice(88231)","source":"billing-api","text":"{\"invoice_id\": 88231, \"account\": \"acct_4415\", \"total_cents\": 432000, \"currency\": \"usd\", \"status\": \"open\", \"issued\": \"2026-07-28\", \"due\": \"2026-08-27\", \"line_items\": [{\"sku\": \"NP-USAGE\", \"desc\": \"Metered input tokens, July\", \"qty\": 4800000, \"unit_price_cents\": 0.009}, {\"sku\": \"NP-SUPPORT\", \"desc\": \"Priority support\", \"qty\": 1, \"unit_price_cents\": 49900}]}"},{"id":"r-002","kind":"tool_result","title":"get_account(acct_4415)","source":"crm-api","text":"{\"account_id\": \"acct_4415\", \"name\": \"Meridian Analytics\", \"plan\": \"scale\", \"payment_method\": \"card_visa_6411\", \"delinquent\": false, \"since\": \"2025-11-03\", \"owner\": \"dana@meridiananalytics.com\"}"},{"id":"r-003","kind":"external_data","title":"Data retention policy v3","source":"handbook","text":"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility."},{"id":"r-004","kind":"external_data","title":"Refund policy v4, section 2","source":"handbook","text":"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible."},{"id":"r-005","kind":"external_data","title":"Refund policy v4, section 3 (exceptions)","source":"handbook","text":"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered."},{"id":"r-006","kind":"tool_result","title":"get_usage(acct_4415, july)","source":"metering-api","text":"{\"account_id\": \"acct_4415\", \"period\": \"2026-07\", \"input_tokens\": 4800000, \"requests\": 1210, \"stand_downs\": 34, \"charged_tokens\": 4646000}"},{"id":"r-007","kind":"tool_result","title":"get_open_tickets(acct_9902)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5488\", \"subject\": \"API key rotation question\", \"opened\": \"2026-08-02\", \"status\": \"closed\", \"assignee\": \"support-lead-1\"}]}"},{"id":"r-008","kind":"user_input","title":null,"source":null,"text":"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?"},{"id":"r-009","kind":"external_data","title":"Credit policy v2","source":"handbook","text":"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause."},{"id":"r-012","kind":"tool_result","title":"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)","source":"metering-api","text":"{\"keys\": [{\"key_id\": \"np_key_a1\", \"requests\": 980, \"user_agent\": \"meridian-batch/2.1\", \"tokens\": 3100000}, {\"key_id\": \"np_key_b2\", \"requests\": 230, \"user_agent\": \"meridian-app/1.4\", \"tokens\": 1700000}], \"note\": \"np_key_a1 traffic stops 2026-07-19T14:02Z\"}"},{"id":"r-013","kind":"external_data","title":"Q2 headcount planning notes","source":"internal-ops","text":"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3."},{"id":"r-014","kind":"tool_result","title":"get_invoice(55102)","source":"billing-api","text":"{\"invoice_id\": 55102, \"account\": \"acct_2210\", \"total_cents\": 18900, \"currency\": \"usd\", \"status\": \"paid\", \"issued\": \"2026-07-15\", \"due\": \"2026-08-14\"}"},{"id":"r-015","kind":"external_data","title":"Q3 marketing newsletter draft","source":"marketing","text":"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September."},{"id":"r-016","kind":"external_data","title":"Office move logistics","source":"internal-ops","text":"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes."},{"id":"r-017","kind":"tool_result","title":"get_open_tickets(acct_4415)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5521\", \"subject\": \"July usage dispute\", \"opened\": \"2026-08-05\", \"status\": \"open\", \"assignee\": \"support-lead-2\"}]}"},{"id":"r-018","kind":"tool_result","title":"get_open_tickets(acct_2210)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5502\", \"subject\": \"Login issue after SSO migration\", \"opened\": \"2026-08-01\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}"},{"id":"r-019","kind":"external_data","title":"Vacation and PTO policy","source":"handbook","text":"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect."},{"id":"r-020","kind":"external_data","title":"Runbook: rotating a compromised API key","source":"ops-wiki","text":"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes."},{"id":"r-021","kind":"llm_response","text":"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown."},{"id":"r-022","kind":"external_data","title":"Customer advisory board Q4 invite draft","source":"marketing","text":"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support."},{"id":"r-023","kind":"tool_result","title":"get_account(acct_9902)","source":"crm-api","text":"{\"account_id\": \"acct_9902\", \"name\": \"Colby Fixtures\", \"plan\": \"growth\", \"payment_method\": \"card_mc_2290\", \"delinquent\": false, \"since\": \"2026-01-14\", \"owner\": \"ops@colbyfixtures.com\"}"},{"id":"r-026","kind":"tool_result","title":"get_open_tickets(acct_5511)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5510\", \"subject\": \"Feature request: CSV export for usage analytics\", \"opened\": \"2026-08-03\", \"status\": \"open\", \"assignee\": \"support-lead-1\"}]}"},{"id":"r-027","kind":"external_data","title":"Q3 all-hands agenda","source":"internal-ops","text":"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q\u0026A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live."},{"id":"r-029","kind":"external_data","title":"Marketing site refresh, visual only","source":"marketing","text":"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only."},{"id":"r-031","kind":"tool_result","title":"get_open_tickets(acct_6630)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5477\", \"subject\": \"Onboarding walkthrough request\", \"opened\": \"2026-07-30\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}"},{"id":"r-032","kind":"external_data","title":"On-call rotation for September","source":"internal-ops","text":"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead."},{"id":"r-033","kind":"external_data","title":"Partner co-marketing webinar recap","source":"marketing","text":"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week."},{"id":"r-034","kind":"external_data","title":"Conference room booking policy","source":"handbook","text":"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing."},{"id":"r-035","kind":"external_data","title":"Blog editorial calendar, Q4","source":"marketing","text":"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication."},{"id":"r-036","kind":"external_data","title":"Kitchen and supplies restock schedule","source":"internal-ops","text":"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week."}],"isRequired":true,"uniqueKey":"oneOf.0.records","typeLabel":"object[]"},"task":{"type":"object","required":["prompt"],"description":"The query the selected context has to serve.","properties":{"prompt":{"type":"string","description":"What the model is being asked to do, and the primary relevance\nsignal. **Metered**, and counted against your per-request ceiling.\n","examples":["Can this invoice still be refunded?"],"example":"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?","isRequired":true,"uniqueKey":"oneOf.0.task.prompt","typeLabel":"string"},"tool_name":{"oneOf":[{"type":"string","description":"The tool about to be called, when the selection serves a tool call.","example":"resolve_billing_dispute","uniqueKey":"oneOf.0.task.tool_name.oneOf.0","typeLabel":"string"},{"type":"null","description":"The tool about to be called, when the selection serves a tool call.","example":"resolve_billing_dispute","uniqueKey":"oneOf.0.task.tool_name.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.task.tool_name","typeLabel":"string | null"},"required_record_ids":{"type":"array","items":{"type":"string","uniqueKey":"oneOf.0.task.required_record_ids.items.[INDEX]","typeLabel":"string"},"default":[],"description":"Records that must appear in the selection. **This field does not\npin**: ids here are matched against the engine's internal record\nidentity rather than against `records[].id`, so they match nothing.\nTo guarantee a record reaches your prompt, keep it out of `records[]`\nand concatenate it around `rendered_context`. See *Records and\ntasks*.\n","uniqueKey":"oneOf.0.task.required_record_ids","typeLabel":"string[]"},"parent_record_ids":{"type":"array","items":{"type":"string","uniqueKey":"oneOf.0.task.parent_record_ids.items.[INDEX]","typeLabel":"string"},"default":[],"description":"Records this task descends from, for lineage signals. **Matched the\nsame way as `required_record_ids`, and inert for the same reason.**\n","uniqueKey":"oneOf.0.task.parent_record_ids","typeLabel":"string[]"},"keywords":{"type":"array","items":{"type":"string","uniqueKey":"oneOf.0.task.keywords.items.[INDEX]","typeLabel":"string"},"default":[],"uniqueKey":"oneOf.0.task.keywords","typeLabel":"string[]"},"tags":{"type":"array","items":{"type":"string","uniqueKey":"oneOf.0.task.tags.items.[INDEX]","typeLabel":"string"},"default":[],"uniqueKey":"oneOf.0.task.tags","typeLabel":"string[]"},"step_id":{"oneOf":[{"type":"string","uniqueKey":"oneOf.0.task.step_id.oneOf.0","typeLabel":"string"},{"type":"null","uniqueKey":"oneOf.0.task.step_id.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.task.step_id","typeLabel":"string | null"},"recent_prompts":{"type":"array","items":{"type":"string","uniqueKey":"oneOf.0.task.recent_prompts.items.[INDEX]","typeLabel":"string"},"default":[],"description":"Prior-step prompts, oldest to newest. **They do not feed selection**,\nand they are counted against your per-request ceiling and by the\nmeter, so send a few or none. See *Records and tasks*.\n","uniqueKey":"oneOf.0.task.recent_prompts","typeLabel":"string[]"},"output_mode":{"oneOf":[{"type":"string","description":"A hint about the shape of the answer being generated.","uniqueKey":"oneOf.0.task.output_mode.oneOf.0","typeLabel":"string"},{"type":"null","description":"A hint about the shape of the answer being generated.","uniqueKey":"oneOf.0.task.output_mode.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.task.output_mode","typeLabel":"string | null"},"output_token_budget":{"oneOf":[{"type":"integer","description":"How many tokens the downstream answer is expected to occupy.","uniqueKey":"oneOf.0.task.output_token_budget.oneOf.0","typeLabel":"integer"},{"type":"null","description":"How many tokens the downstream answer is expected to occupy.","uniqueKey":"oneOf.0.task.output_token_budget.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.task.output_token_budget","typeLabel":"integer | null"}},"example":{"prompt":"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?","tool_name":"resolve_billing_dispute"},"isRequired":true,"uniqueKey":"oneOf.0.task","typeLabel":"object"},"budget":{"type":"object","required":["max_context_tokens"],"description":"The operating point, in arm-neutral quantities only. **No method-tuning\nknobs appear here or anywhere else in the request**: the selection\nconfiguration resolves server-side from the `operating_point` label.\n","properties":{"max_context_tokens":{"type":"integer","description":"The token allowance the selection must fit inside. Set it from what\nyour downstream call accepts and leave it there; selections at\ndifferent budgets are different computations, so do not sweep it\nlooking for a quality optimum. See *Operating points*.\n","examples":[4000],"example":900,"isRequired":true,"uniqueKey":"oneOf.0.budget.max_context_tokens","typeLabel":"integer"},"autochunk":{"type":"boolean","default":false,"description":"Split each record into candidate passages server-side before\nselection, so that a single large document can be selected *within*\nrather than only kept or dropped whole. Opt-in: omitted or `false`\nleaves every record intact.\n\nThe post-split candidate count is capped; over it the request is\nrefused with `413` and `limit_name: \"autochunk_candidates\"`. See\n*Limits*.\n\nNot supported on every operating point. On a label that does not\naccept it the request is refused with `400`, `reason:\n\"autochunk_unsupported_operating_point\"`, rather than being served\nwith the flag quietly ignored.\n","example":true,"uniqueKey":"oneOf.0.budget.autochunk","typeLabel":"boolean"},"operating_point":{"oneOf":[{"type":"string","description":"An opaque, versioned, immutable label naming a frozen configuration.\n**Always send one**, because omitting it inherits the server's\ndefault and that default moves when a new label is minted. Read the\nregistry at `/v1/operating-points`.\n","example":"np-2026-08-r4","uniqueKey":"oneOf.0.budget.operating_point.oneOf.0","typeLabel":"string"},{"type":"null","description":"An opaque, versioned, immutable label naming a frozen configuration.\n**Always send one**, because omitting it inherits the server's\ndefault and that default moves when a new label is minted. Read the\nregistry at `/v1/operating-points`.\n","example":"np-2026-08-r4","uniqueKey":"oneOf.0.budget.operating_point.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.budget.operating_point","typeLabel":"string | null"},"max_records":{"oneOf":[{"type":"integer","description":"Cap the number of records in the selection. Distinct from the tier's per-request record ceiling, which rejects the request instead. When omitted the selection is capped at 18 records, so enumeration-style callers should set it.","uniqueKey":"oneOf.0.budget.max_records.oneOf.0","typeLabel":"integer"},{"type":"null","description":"Cap the number of records in the selection. Distinct from the tier's per-request record ceiling, which rejects the request instead. When omitted the selection is capped at 18 records, so enumeration-style callers should set it.","uniqueKey":"oneOf.0.budget.max_records.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.budget.max_records","typeLabel":"integer | null"},"max_excerpt_tokens_per_record":{"oneOf":[{"type":"integer","description":"Cap the excerpt taken from any single record. **This field has no\neffect**; per-record excerpt size resolves from the operating point.\n","uniqueKey":"oneOf.0.budget.max_excerpt_tokens_per_record.oneOf.0","typeLabel":"integer"},{"type":"null","description":"Cap the excerpt taken from any single record. **This field has no\neffect**; per-record excerpt size resolves from the operating point.\n","uniqueKey":"oneOf.0.budget.max_excerpt_tokens_per_record.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.budget.max_excerpt_tokens_per_record","typeLabel":"integer | null"},"mode":{"type":"string","enum":["fixed","adaptive"],"default":"fixed","description":"`fixed` selects once against `max_context_tokens`. `adaptive` selects\nat `adaptive.initial_tokens` and can escalate through the later rungs,\nreporting every rung attempted in `attempted_budget_tokens[]`. See *Adaptive budget*.\n","uniqueKey":"oneOf.0.budget.mode","typeLabel":"enum\u003cstring>"},"adaptive":{"oneOf":[{"type":"object","description":"The escalation ladder. **`mode: \"adaptive\"` with this absent runs as\na fixed-budget request** rather than erroring, so send it whenever\nyou mean adaptive.\n","required":["initial_tokens"],"properties":{"initial_tokens":{"type":"integer","description":"The first rung. Selection is attempted here first.","isRequired":true,"uniqueKey":"oneOf.0.budget.adaptive.oneOf.0.initial_tokens","typeLabel":"integer"},"escalation_tokens":{"type":"array","items":{"type":"integer","uniqueKey":"oneOf.0.budget.adaptive.oneOf.0.escalation_tokens.items.[INDEX]","typeLabel":"integer"},"default":[],"description":"Further rungs, ascending. Each rung attempted is a full selection pass, so a workload that always escalates does several times the work.","uniqueKey":"oneOf.0.budget.adaptive.oneOf.0.escalation_tokens","typeLabel":"integer[]"},"allow_full_context_fallback":{"type":"boolean","default":true,"description":"Whether the ladder may end in passing the whole context through. With\nit `false`, a request the ladder cannot satisfy returns the best\nselection it found rather than everything. See *Adaptive budget*.\n","uniqueKey":"oneOf.0.budget.adaptive.oneOf.0.allow_full_context_fallback","typeLabel":"boolean"}},"uniqueKey":"oneOf.0.budget.adaptive.oneOf.0","typeLabel":"object"},{"type":"null","description":"The escalation ladder. **`mode: \"adaptive\"` with this absent runs as\na fixed-budget request** rather than erroring, so send it whenever\nyou mean adaptive.\n","uniqueKey":"oneOf.0.budget.adaptive.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.budget.adaptive","typeLabel":"object | null"},"require_evidence_coverage":{"oneOf":[{"type":"boolean","description":"Ask Needlepath to stand down to your full context rather than return a selection that does not\ncover the task's evidence, and to summarise the result in `safety`. **Takes effect only with `mode:\n\"adaptive\"`**.\n","uniqueKey":"oneOf.0.budget.require_evidence_coverage.oneOf.0","typeLabel":"boolean"},{"type":"null","description":"Ask Needlepath to stand down to your full context rather than return a selection that does not\ncover the task's evidence, and to summarise the result in `safety`. **Takes effect only with `mode:\n\"adaptive\"`**.\n","uniqueKey":"oneOf.0.budget.require_evidence_coverage.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.0.budget.require_evidence_coverage","typeLabel":"boolean | null"}},"example":{"max_context_tokens":900,"operating_point":"np-2026-08-r4"},"isRequired":true,"uniqueKey":"oneOf.0.budget","typeLabel":"object"},"request_id":{"type":"string","description":"Your correlation id, echoed back byte-for-byte. **Optional**:\nit is sent-side only, a caller correlation id we never require;\nabsent is echoed back as `\"\"`. When sent, keep it to **≤ 128\ncharacters of `[A-Za-z0-9._:-]`**, and put no record content,\ncustomer text or credentials in it, because it reaches our logs. See\n*Retention and trust*.\n","example":"req-2026-09-03-0001","uniqueKey":"oneOf.0.request_id","typeLabel":"string"},"render":{"type":"boolean","default":true,"description":"Ask for `rendered_context`, a model-facing string assembled from the\nselection. `render` has no effect; `rendered_context` is always\nreturned. Ignore it client-side if unwanted.\n","example":true,"uniqueKey":"oneOf.0.render","typeLabel":"boolean"},"render_format":{"type":"string","enum":["plain","hybrid"],"default":"plain","description":"`plain` leaves excerpts as text. `hybrid` additionally permits a\nstructured excerpt to be re-encoded into a more compact form, and\n`excerpt_format` reports which form was used.\n**Send `plain` if you re-parse excerpts as JSON.**\n","example":"plain","uniqueKey":"oneOf.0.render_format","typeLabel":"enum\u003cstring>"},"return_per_record":{"type":"boolean","default":true,"description":"Include the `selected[]` per-record detail: score, reason, excerpt\nand token count. Set `false` for `rendered_context` plus the token\narithmetic only, which is a materially smaller response body.\n","example":true,"uniqueKey":"oneOf.0.return_per_record","typeLabel":"boolean"},"security_mode":{"type":"string","enum":["off","audit","quarantine","enforce"],"description":"Security screening of the context this request delivers. Per request,\nand available to any caller. Omitted, the request keeps the operating\npoint's setting: `enforce` on `np-2026-10-r7` and `np-2026-10-r8`, and `off`\non every other listed operating point. Sent, it replaces that setting for this request\nonly.\n\n`audit` screens and reports in the receipt without changing what is\ndelivered. `quarantine` removes flagged spans from the delivered context\nand marks each removal in place. `enforce` does the same and, when nothing\ndeliverable remains, returns `outcome: blocked` with no context. See\n*Errors* for the two outcomes and *How billing works* for the charge.\n","example":"audit","uniqueKey":"oneOf.0.security_mode","typeLabel":"enum\u003cstring>"}},"uniqueKey":"oneOf.0","typeLabel":"object"},{"type":"object","description":"The simple shape: send free-form `text` instead of pre-split\n`records[]`. Needlepath splits it on blank lines and assigns each\nresulting record a content-hash id (`sha256:` plus the first 16 hex\ncharacters of the SHA-256 of that record's own UTF-8 bytes, so the\nsame paragraph always comes back as the same id), then serves the\nexact same `/v1/context/select` path a hand-built `records[]` call\nwould take: same meter, same engine, same response shape.\n`text` and `records` are mutually exclusive: sending both is a `400`\nwith `error: \"text_and_records_both_set\"`. See *The simple shape* in\nthe quickstart.\n","required":["text","task","budget"],"example":{"text":"Customer dana@meridiananalytics.com disputes the July invoice: roughly a third of the usage came from a runaway integration on their side, shut down on July 19. They ask for a refund or credit for the excess.\n\nRefund policy: refunds are issued only for platform-caused overcharges verified against receipts. Service credits differ: for customer-caused overuse, credits up to 25% of the disputed amount may be granted once per account per year, applied to the next invoice.\n\nThe Austin office move completes August 15. Badge access transfers automatically, desk assignments are posted on the intranet, the fourth-floor kitchen closes during the transition, visitor parking moves to the north garage, and commuter benefits need updating by August 10 for anyone using transit passes. Facilities will run tours on Friday.\n\nThe Q3 marketing case-study series features five accounts and is scheduled for September publication; drafts are with legal review and the design team is preparing pull quotes, hero images, and a landing page refresh to accompany the launch announcement.\n\nThe support Slack workspace migrates to a new domain next Tuesday. Existing channels and history carry over automatically; only bookmarked links need updating.\n\nQuarterly OKR review is scheduled for the last week of the quarter, with each team submitting a one-page summary two business days ahead.\n\nThe status page gained a subscribe-by-email option this release, alongside the existing RSS feed and webhook.\n\nConference room booking now supports recurring holds up to eight weeks out, previously capped at two.","task":{"prompt":"What portion of the disputed usage was customer-caused, and does that qualify it for a refund or a service credit?"},"budget":{"max_context_tokens":400}},"properties":{"text":{"type":"string","description":"Free text to split into records on one-or-more blank lines.\nWhitespace-only chunks are dropped. Metered the same as the\n`text` of any derived record would be.\n","isRequired":true,"uniqueKey":"oneOf.1.text","typeLabel":"string"},"task":{"type":"object","required":["prompt"],"description":"The query the selected context has to serve.","properties":{"prompt":{"type":"string","description":"What the model is being asked to do, and the primary relevance\nsignal. **Metered**, and counted against your per-request ceiling.\n","examples":["Can this invoice still be refunded?"],"example":"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?","isRequired":true,"uniqueKey":"oneOf.1.task.prompt","typeLabel":"string"},"tool_name":{"oneOf":[{"type":"string","description":"The tool about to be called, when the selection serves a tool call.","example":"resolve_billing_dispute","uniqueKey":"oneOf.1.task.tool_name.oneOf.0","typeLabel":"string"},{"type":"null","description":"The tool about to be called, when the selection serves a tool call.","example":"resolve_billing_dispute","uniqueKey":"oneOf.1.task.tool_name.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.1.task.tool_name","typeLabel":"string | null"},"required_record_ids":{"type":"array","items":{"type":"string","uniqueKey":"oneOf.1.task.required_record_ids.items.[INDEX]","typeLabel":"string"},"default":[],"description":"Records that must appear in the selection. **This field does not\npin**: ids here are matched against the engine's internal record\nidentity rather than against `records[].id`, so they match nothing.\nTo guarantee a record reaches your prompt, keep it out of `records[]`\nand concatenate it around `rendered_context`. See *Records and\ntasks*.\n","uniqueKey":"oneOf.1.task.required_record_ids","typeLabel":"string[]"},"parent_record_ids":{"type":"array","items":{"type":"string","uniqueKey":"oneOf.1.task.parent_record_ids.items.[INDEX]","typeLabel":"string"},"default":[],"description":"Records this task descends from, for lineage signals. **Matched the\nsame way as `required_record_ids`, and inert for the same reason.**\n","uniqueKey":"oneOf.1.task.parent_record_ids","typeLabel":"string[]"},"keywords":{"type":"array","items":{"type":"string","uniqueKey":"oneOf.1.task.keywords.items.[INDEX]","typeLabel":"string"},"default":[],"uniqueKey":"oneOf.1.task.keywords","typeLabel":"string[]"},"tags":{"type":"array","items":{"type":"string","uniqueKey":"oneOf.1.task.tags.items.[INDEX]","typeLabel":"string"},"default":[],"uniqueKey":"oneOf.1.task.tags","typeLabel":"string[]"},"step_id":{"oneOf":[{"type":"string","uniqueKey":"oneOf.1.task.step_id.oneOf.0","typeLabel":"string"},{"type":"null","uniqueKey":"oneOf.1.task.step_id.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.1.task.step_id","typeLabel":"string | null"},"recent_prompts":{"type":"array","items":{"type":"string","uniqueKey":"oneOf.1.task.recent_prompts.items.[INDEX]","typeLabel":"string"},"default":[],"description":"Prior-step prompts, oldest to newest. **They do not feed selection**,\nand they are counted against your per-request ceiling and by the\nmeter, so send a few or none. See *Records and tasks*.\n","uniqueKey":"oneOf.1.task.recent_prompts","typeLabel":"string[]"},"output_mode":{"oneOf":[{"type":"string","description":"A hint about the shape of the answer being generated.","uniqueKey":"oneOf.1.task.output_mode.oneOf.0","typeLabel":"string"},{"type":"null","description":"A hint about the shape of the answer being generated.","uniqueKey":"oneOf.1.task.output_mode.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.1.task.output_mode","typeLabel":"string | null"},"output_token_budget":{"oneOf":[{"type":"integer","description":"How many tokens the downstream answer is expected to occupy.","uniqueKey":"oneOf.1.task.output_token_budget.oneOf.0","typeLabel":"integer"},{"type":"null","description":"How many tokens the downstream answer is expected to occupy.","uniqueKey":"oneOf.1.task.output_token_budget.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.1.task.output_token_budget","typeLabel":"integer | null"}},"isRequired":true,"uniqueKey":"oneOf.1.task","typeLabel":"object"},"budget":{"type":"object","required":["max_context_tokens"],"description":"The operating point, in arm-neutral quantities only. **No method-tuning\nknobs appear here or anywhere else in the request**: the selection\nconfiguration resolves server-side from the `operating_point` label.\n","properties":{"max_context_tokens":{"type":"integer","description":"The token allowance the selection must fit inside. Set it from what\nyour downstream call accepts and leave it there; selections at\ndifferent budgets are different computations, so do not sweep it\nlooking for a quality optimum. See *Operating points*.\n","examples":[4000],"example":900,"isRequired":true,"uniqueKey":"oneOf.1.budget.max_context_tokens","typeLabel":"integer"},"autochunk":{"type":"boolean","default":false,"description":"Split each record into candidate passages server-side before\nselection, so that a single large document can be selected *within*\nrather than only kept or dropped whole. Opt-in: omitted or `false`\nleaves every record intact.\n\nThe post-split candidate count is capped; over it the request is\nrefused with `413` and `limit_name: \"autochunk_candidates\"`. See\n*Limits*.\n\nNot supported on every operating point. On a label that does not\naccept it the request is refused with `400`, `reason:\n\"autochunk_unsupported_operating_point\"`, rather than being served\nwith the flag quietly ignored.\n","example":true,"uniqueKey":"oneOf.1.budget.autochunk","typeLabel":"boolean"},"operating_point":{"oneOf":[{"type":"string","description":"An opaque, versioned, immutable label naming a frozen configuration.\n**Always send one**, because omitting it inherits the server's\ndefault and that default moves when a new label is minted. Read the\nregistry at `/v1/operating-points`.\n","example":"np-2026-08-r4","uniqueKey":"oneOf.1.budget.operating_point.oneOf.0","typeLabel":"string"},{"type":"null","description":"An opaque, versioned, immutable label naming a frozen configuration.\n**Always send one**, because omitting it inherits the server's\ndefault and that default moves when a new label is minted. Read the\nregistry at `/v1/operating-points`.\n","example":"np-2026-08-r4","uniqueKey":"oneOf.1.budget.operating_point.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.1.budget.operating_point","typeLabel":"string | null"},"max_records":{"oneOf":[{"type":"integer","description":"Cap the number of records in the selection. Distinct from the tier's per-request record ceiling, which rejects the request instead. When omitted the selection is capped at 18 records, so enumeration-style callers should set it.","uniqueKey":"oneOf.1.budget.max_records.oneOf.0","typeLabel":"integer"},{"type":"null","description":"Cap the number of records in the selection. Distinct from the tier's per-request record ceiling, which rejects the request instead. When omitted the selection is capped at 18 records, so enumeration-style callers should set it.","uniqueKey":"oneOf.1.budget.max_records.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.1.budget.max_records","typeLabel":"integer | null"},"max_excerpt_tokens_per_record":{"oneOf":[{"type":"integer","description":"Cap the excerpt taken from any single record. **This field has no\neffect**; per-record excerpt size resolves from the operating point.\n","uniqueKey":"oneOf.1.budget.max_excerpt_tokens_per_record.oneOf.0","typeLabel":"integer"},{"type":"null","description":"Cap the excerpt taken from any single record. **This field has no\neffect**; per-record excerpt size resolves from the operating point.\n","uniqueKey":"oneOf.1.budget.max_excerpt_tokens_per_record.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.1.budget.max_excerpt_tokens_per_record","typeLabel":"integer | null"},"mode":{"type":"string","enum":["fixed","adaptive"],"default":"fixed","description":"`fixed` selects once against `max_context_tokens`. `adaptive` selects\nat `adaptive.initial_tokens` and can escalate through the later rungs,\nreporting every rung attempted in `attempted_budget_tokens[]`. See *Adaptive budget*.\n","uniqueKey":"oneOf.1.budget.mode","typeLabel":"enum\u003cstring>"},"adaptive":{"oneOf":[{"type":"object","description":"The escalation ladder. **`mode: \"adaptive\"` with this absent runs as\na fixed-budget request** rather than erroring, so send it whenever\nyou mean adaptive.\n","required":["initial_tokens"],"properties":{"initial_tokens":{"type":"integer","description":"The first rung. Selection is attempted here first.","isRequired":true,"uniqueKey":"oneOf.1.budget.adaptive.oneOf.0.initial_tokens","typeLabel":"integer"},"escalation_tokens":{"type":"array","items":{"type":"integer","uniqueKey":"oneOf.1.budget.adaptive.oneOf.0.escalation_tokens.items.[INDEX]","typeLabel":"integer"},"default":[],"description":"Further rungs, ascending. Each rung attempted is a full selection pass, so a workload that always escalates does several times the work.","uniqueKey":"oneOf.1.budget.adaptive.oneOf.0.escalation_tokens","typeLabel":"integer[]"},"allow_full_context_fallback":{"type":"boolean","default":true,"description":"Whether the ladder may end in passing the whole context through. With\nit `false`, a request the ladder cannot satisfy returns the best\nselection it found rather than everything. See *Adaptive budget*.\n","uniqueKey":"oneOf.1.budget.adaptive.oneOf.0.allow_full_context_fallback","typeLabel":"boolean"}},"uniqueKey":"oneOf.1.budget.adaptive.oneOf.0","typeLabel":"object"},{"type":"null","description":"The escalation ladder. **`mode: \"adaptive\"` with this absent runs as\na fixed-budget request** rather than erroring, so send it whenever\nyou mean adaptive.\n","uniqueKey":"oneOf.1.budget.adaptive.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.1.budget.adaptive","typeLabel":"object | null"},"require_evidence_coverage":{"oneOf":[{"type":"boolean","description":"Ask Needlepath to stand down to your full context rather than return a selection that does not\ncover the task's evidence, and to summarise the result in `safety`. **Takes effect only with `mode:\n\"adaptive\"`**.\n","uniqueKey":"oneOf.1.budget.require_evidence_coverage.oneOf.0","typeLabel":"boolean"},{"type":"null","description":"Ask Needlepath to stand down to your full context rather than return a selection that does not\ncover the task's evidence, and to summarise the result in `safety`. **Takes effect only with `mode:\n\"adaptive\"`**.\n","uniqueKey":"oneOf.1.budget.require_evidence_coverage.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.1.budget.require_evidence_coverage","typeLabel":"boolean | null"}},"isRequired":true,"uniqueKey":"oneOf.1.budget","typeLabel":"object"},"request_id":{"type":"string","description":"Your correlation id, echoed back byte-for-byte. **Optional**\non this shape too: it is sent-side only, a caller correlation id\nwe never require; absent is echoed back as `\"\"`. See\n`ContextRequest.request_id` for the charset and length bound that\napply when you do send one.\n","uniqueKey":"oneOf.1.request_id","typeLabel":"string"},"security_mode":{"type":"string","enum":["off","audit","quarantine","enforce"],"description":"Security screening, as on `ContextRequest.security_mode`. The derived\nrecords carry no `source_kind`, so the receipt reports `unknown`.\n","uniqueKey":"oneOf.1.security_mode","typeLabel":"enum\u003cstring>"}},"uniqueKey":"oneOf.1","typeLabel":"object"}],"uniqueKey":"","typeLabel":"object"},"examples":{"engages":{"title":"engages","value":{"request_id":"req-2026-09-03-0001","records":[{"id":"r-001","kind":"tool_result","title":"get_invoice(88231)","source":"billing-api","text":"{\"invoice_id\": 88231, \"account\": \"acct_4415\", \"total_cents\": 432000, \"currency\": \"usd\", \"status\": \"open\", \"issued\": \"2026-07-28\", \"due\": \"2026-08-27\", \"line_items\": [{\"sku\": \"NP-USAGE\", \"desc\": \"Metered input tokens, July\", \"qty\": 4800000, \"unit_price_cents\": 0.009}, {\"sku\": \"NP-SUPPORT\", \"desc\": \"Priority support\", \"qty\": 1, \"unit_price_cents\": 49900}]}"},{"id":"r-002","kind":"tool_result","title":"get_account(acct_4415)","source":"crm-api","text":"{\"account_id\": \"acct_4415\", \"name\": \"Meridian Analytics\", \"plan\": \"scale\", \"payment_method\": \"card_visa_6411\", \"delinquent\": false, \"since\": \"2025-11-03\", \"owner\": \"dana@meridiananalytics.com\"}"},{"id":"r-003","kind":"external_data","title":"Data retention policy v3","source":"handbook","text":"Customer-supplied records are retained for 30 days after a support ticket closes, then purged. Internal audit logs of access to those records are retained for one year. This policy governs storage, not billing, and has no bearing on refund or credit eligibility."},{"id":"r-004","kind":"external_data","title":"Refund policy v4, section 2","source":"handbook","text":"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible."},{"id":"r-005","kind":"external_data","title":"Refund policy v4, section 3 (exceptions)","source":"handbook","text":"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered."},{"id":"r-006","kind":"tool_result","title":"get_usage(acct_4415, july)","source":"metering-api","text":"{\"account_id\": \"acct_4415\", \"period\": \"2026-07\", \"input_tokens\": 4800000, \"requests\": 1210, \"stand_downs\": 34, \"charged_tokens\": 4646000}"},{"id":"r-007","kind":"tool_result","title":"get_open_tickets(acct_9902)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5488\", \"subject\": \"API key rotation question\", \"opened\": \"2026-08-02\", \"status\": \"closed\", \"assignee\": \"support-lead-1\"}]}"},{"id":"r-008","kind":"user_input","title":null,"source":null,"text":"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?"},{"id":"r-009","kind":"external_data","title":"Credit policy v2","source":"handbook","text":"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method. Credits require the account owner's written acknowledgement of the cause."},{"id":"r-012","kind":"tool_result","title":"get_key_traffic(acct_4415, 2026-07-01..2026-07-19)","source":"metering-api","text":"{\"keys\": [{\"key_id\": \"np_key_a1\", \"requests\": 980, \"user_agent\": \"meridian-batch/2.1\", \"tokens\": 3100000}, {\"key_id\": \"np_key_b2\", \"requests\": 230, \"user_agent\": \"meridian-app/1.4\", \"tokens\": 1700000}], \"note\": \"np_key_a1 traffic stops 2026-07-19T14:02Z\"}"},{"id":"r-013","kind":"external_data","title":"Q2 headcount planning notes","source":"internal-ops","text":"The Q2 headcount review covered open requisitions across support and account management. Two backfills were approved pending final budget sign-off from finance; the rest carry into Q3."},{"id":"r-014","kind":"tool_result","title":"get_invoice(55102)","source":"billing-api","text":"{\"invoice_id\": 55102, \"account\": \"acct_2210\", \"total_cents\": 18900, \"currency\": \"usd\", \"status\": \"paid\", \"issued\": \"2026-07-15\", \"due\": \"2026-08-14\"}"},{"id":"r-015","kind":"external_data","title":"Q3 marketing newsletter draft","source":"marketing","text":"Meridian Analytics is one of several accounts featured in our upcoming case-study series. The draft highlights their 40% pipeline acceleration after adopting the platform. Publication is scheduled for September."},{"id":"r-016","kind":"external_data","title":"Office move logistics","source":"internal-ops","text":"The Austin office move completes August 15. Badge access transfers automatically. Update your commuter benefits by August 10 if you use transit passes."},{"id":"r-017","kind":"tool_result","title":"get_open_tickets(acct_4415)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5521\", \"subject\": \"July usage dispute\", \"opened\": \"2026-08-05\", \"status\": \"open\", \"assignee\": \"support-lead-2\"}]}"},{"id":"r-018","kind":"tool_result","title":"get_open_tickets(acct_2210)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5502\", \"subject\": \"Login issue after SSO migration\", \"opened\": \"2026-08-01\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}"},{"id":"r-019","kind":"external_data","title":"Vacation and PTO policy","source":"handbook","text":"Full-time staff accrue 15 days of PTO per year, front-loaded each January. Unused days above a 5-day carryover are paid out at year end. This policy applies to internal staff only and has no customer-facing effect."},{"id":"r-020","kind":"external_data","title":"Runbook: rotating a compromised API key","source":"ops-wiki","text":"If a key is suspected compromised: revoke it immediately from the dashboard, mint a replacement, and audit the last 30 days of request logs for the revoked key. Notify the account owner within one business hour. This does not apply to routine billing disputes."},{"id":"r-021","kind":"llm_response","text":"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown."},{"id":"r-022","kind":"external_data","title":"Customer advisory board Q4 invite draft","source":"marketing","text":"Draft invitation for the Q4 customer advisory board: eight accounts, half-day session, catered lunch, and a closing networking hour. Invitations go out via the account team, not support."},{"id":"r-023","kind":"tool_result","title":"get_account(acct_9902)","source":"crm-api","text":"{\"account_id\": \"acct_9902\", \"name\": \"Colby Fixtures\", \"plan\": \"growth\", \"payment_method\": \"card_mc_2290\", \"delinquent\": false, \"since\": \"2026-01-14\", \"owner\": \"ops@colbyfixtures.com\"}"},{"id":"r-026","kind":"tool_result","title":"get_open_tickets(acct_5511)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5510\", \"subject\": \"Feature request: CSV export for usage analytics\", \"opened\": \"2026-08-03\", \"status\": \"open\", \"assignee\": \"support-lead-1\"}]}"},{"id":"r-027","kind":"external_data","title":"Q3 all-hands agenda","source":"internal-ops","text":"Agenda: Q3 numbers recap, the Austin office move timeline, two customer case studies, and a Q\u0026A. Scheduled for the last Thursday of the quarter, recorded for anyone who cannot attend live."},{"id":"r-029","kind":"external_data","title":"Marketing site refresh, visual only","source":"marketing","text":"The marketing homepage and case-study pages move to a refreshed visual design next month. Existing URLs and content are unchanged; this is a styling pass only."},{"id":"r-031","kind":"tool_result","title":"get_open_tickets(acct_6630)","source":"support-api","text":"{\"tickets\": [{\"id\": \"T-5477\", \"subject\": \"Onboarding walkthrough request\", \"opened\": \"2026-07-30\", \"status\": \"closed\", \"assignee\": \"support-lead-3\"}]}"},{"id":"r-032","kind":"external_data","title":"On-call rotation for September","source":"internal-ops","text":"September on-call: week 1 support-lead-1, week 2 support-lead-2, week 3 support-lead-3, week 4 support-lead-1. Swap requests go through the usual calendar invite at least 48 hours ahead."},{"id":"r-033","kind":"external_data","title":"Partner co-marketing webinar recap","source":"marketing","text":"Tuesday's co-marketing webinar drew 140 live attendees, with a recording queued for the newsletter. Follow-up survey responses are due back from the partner team by end of week."},{"id":"r-034","kind":"external_data","title":"Conference room booking policy","source":"handbook","text":"Rooms can be held up to 90 days ahead through the office system. No-shows for two consecutive bookings lose booking privileges for 30 days. This policy is unrelated to customer accounts or billing."},{"id":"r-035","kind":"external_data","title":"Blog editorial calendar, Q4","source":"marketing","text":"Q4 blog calendar: a launch recap in week 1, two customer spotlights in weeks 3 and 6, and a year-in-review post closing out the quarter. Drafts are due to editorial ten business days before publication."},{"id":"r-036","kind":"external_data","title":"Kitchen and supplies restock schedule","source":"internal-ops","text":"Snack and coffee restocks happen every Monday and Thursday. Submit special requests through the office system by end of day Friday for the following week."}],"task":{"prompt":"What does the evidence show about invoice 88231: is the disputed usage customer-caused, and does it qualify for a refund or a service credit?","tool_name":"resolve_billing_dispute"},"budget":{"max_context_tokens":900,"operating_point":"np-2026-08-r4"},"render":true,"render_format":"plain","return_per_record":true}},"stands_down":{"title":"stands_down","value":{"request_id":"req-2026-08-01-0001","records":[{"id":"r-812","kind":"tool_result","title":"get_invoice(4471)","source":"billing-api","text":"{\"invoice_id\": 4471, \"total_cents\": 128400, \"status\": \"open\"}","importance":0},{"id":"r-813","kind":"external_data","title":"Refund policy v4","source":"handbook","text":"Refunds are issued to the original payment method within 10 business days."},{"id":"r-814","kind":"llm_response","text":"I have pulled up the account. One moment."}],"task":{"prompt":"Can this invoice still be refunded?","tool_name":"answer_customer"},"budget":{"max_context_tokens":4000,"operating_point":"np-2026-08-r4"},"render":true,"render_format":"plain","return_per_record":true}},"simple_text":{"title":"simple_text","value":{"text":"Customer dana@meridiananalytics.com disputes the July invoice: roughly a third of the usage came from a runaway integration on their side, shut down on July 19. They ask for a refund or credit for the excess.\n\nRefund policy: refunds are issued only for platform-caused overcharges verified against receipts. Service credits differ: for customer-caused overuse, credits up to 25% of the disputed amount may be granted once per account per year, applied to the next invoice.\n\nThe Austin office move completes August 15. Badge access transfers automatically, desk assignments are posted on the intranet, the fourth-floor kitchen closes during the transition, visitor parking moves to the north garage, and commuter benefits need updating by August 10 for anyone using transit passes. Facilities will run tours on Friday.\n\nThe Q3 marketing case-study series features five accounts and is scheduled for September publication; drafts are with legal review and the design team is preparing pull quotes, hero images, and a landing page refresh to accompany the launch announcement.\n\nThe support Slack workspace migrates to a new domain next Tuesday. Existing channels and history carry over automatically; only bookmarked links need updating.\n\nQuarterly OKR review is scheduled for the last week of the quarter, with each team submitting a one-page summary two business days ahead.\n\nThe status page gained a subscribe-by-email option this release, alongside the existing RSS feed and webhook.\n\nConference room booking now supports recurring holds up to eight weeks out, previously capped at two.","task":{"prompt":"What portion of the disputed usage was customer-caused, and does that qualify it for a refund or a service credit?"},"budget":{"max_context_tokens":400}}}},"exampleType":"examples"}},"exampleType":"examples"},"responses":{"f75d7b68-8ae4-4c70-af37-4aa16418236d":{"description":"A selection. **Includes stand-downs and engine-internal failures**,\nso read `fallback_used` and `selection_error`. This service returns 200\nwith a usable body rather than a 5xx when its own selection pass\nfails, because the correct client behaviour in that case is to send\nthe original context, which the body already contains.\n","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"description":"The selection.\n\n**Required by the contract** (the published client raises if any is\nmissing, or if `request_id` does not echo): `request_id`,\n`rendered_context`, `tokens_before`, `tokens_after`, `tokens_saved`,\n`records_available`, `records_selected`, `fallback_used`, `outcome`,\n`engine_latency_ms`.\n\nEverything else is optional and **new optional fields ship within\n`/v1`**, so ignore what you do not recognise.\n\n**This object is open, and it already carries keys this schema does not\nlist.** Some are operating-point specific, so the exact set varies with\nthe `operating_point` you send. A generated client must tolerate unknown\nkeys rather than reject or drop the response: validate the required\nfields above and pass the rest through. If your generator defaults\n`additionalProperties` to `false`, it will produce a client that current\nresponses already fail.\n","required":["request_id","rendered_context","tokens_before","tokens_after","tokens_saved","records_available","records_selected","fallback_used","outcome","engine_latency_ms"],"properties":{"request_id":{"type":"string","description":"Your `request_id`, echoed byte-for-byte.","isRequired":true,"uniqueKey":"request_id","typeLabel":"string"},"rendered_context":{"type":"string","description":"The model-facing block, assembled from the selection. Always returned.\nWhen security screening removed a span, the removed text is replaced in\nplace by the marker `[QUARANTINED: instruction-like candidate text removed]`;\non `outcome: blocked` this is a placeholder line with none of your content.\n","isRequired":true,"uniqueKey":"rendered_context","typeLabel":"string"},"tokens_before":{"type":"integer","description":"The engine's own accounting of the context available before\nfiltering. **It is not the billing quantity**: the meter also counts\n`record.title`, `task.prompt` and `task.recent_prompts`, so\n`usage.input_tokens` is the larger number. Budget against this, do\nnot reconcile an invoice with it. See *How to recompute your own\nbill*.\n","isRequired":true,"uniqueKey":"tokens_before","typeLabel":"integer"},"tokens_after":{"type":"integer","description":"Context size after selection, on the same engine-internal basis as `tokens_before`.","isRequired":true,"uniqueKey":"tokens_after","typeLabel":"integer"},"tokens_saved":{"type":"integer","description":"`tokens_before - tokens_after`. Zero on a stand-down, which is a correct outcome rather than a failed one.","isRequired":true,"uniqueKey":"tokens_saved","typeLabel":"integer"},"records_available":{"type":"integer","description":"How many records the engine considered.","isRequired":true,"uniqueKey":"records_available","typeLabel":"integer"},"records_selected":{"type":"integer","description":"How many it selected.","isRequired":true,"uniqueKey":"records_selected","typeLabel":"integer"},"outcome":{"type":"string","description":"How the engine resolved this request, at the top level so that you never have to read a nested object to find it.\n\n**An open enum. Do not exhaustively match it**, and do not fail closed on a value you do not recognise: new outcomes ship additively within `/v1`. Current values are `engaged` (records were selected), `escalated` (the eligible full context exceeded the capacity it had to fit inside, so `selected` is empty and `rendered_context` is an empty string), `stood_down` (Needlepath stood down: no selection was returned, so send your full input), and two that appear only when security screening ran, because the request sent `security_mode` or ran on `np-2026-10-r7` or `np-2026-10-r8`: `sanitized_fallback` (a full-context fallback delivered as `rendered_context` with flagged spans removed and marked in place; `records_selected` is 0 and `fallback_used` is false, so send `rendered_context`) and `blocked` (under `enforce`, nothing deliverable remained; no context is returned). See *Errors*.\n\n**This is not the same field as `usage.outcome`, and the two can legitimately disagree on a single response.** This field reports what the *engine* did. `usage.outcome` reports how the request was *priced*, and it resolves selection failures first, so a response can carry `outcome: \"engaged\"` alongside `usage.outcome: \"fallback\"`. Read this field to decide what to do with the response; read `usage.outcome` to explain a charge.\n\n`escalated` returns no context. Treat it as \"use the context you already had\". It is not an error, and it is not a saving. `blocked` returns no context either; the published clients treat it as a decline and continue with the context you already had, and it is charged.\n","examples":["engaged","escalated","stood_down","sanitized_fallback","blocked"],"isRequired":true,"uniqueKey":"outcome","typeLabel":"string"},"fallback_used":{"type":"boolean","description":"`true` means send the context you submitted: the response returns it\nessentially intact. **It does not tell you why**: a stand-down (an empty\nselection with `outcome: stood_down`, or every record returned), an empty\nrecord set and an engine-internal\nexception all produce it. Read `outcome` first, then `selection_error`\nand `format_metrics.engine_fallback_reason` to tell the last two apart.\nDo not read `gate` for this: it can disagree with `outcome`.\nSee *Errors*.\n","isRequired":true,"uniqueKey":"fallback_used","typeLabel":"boolean"},"engine_latency_ms":{"type":"number","format":"double","description":"Server-measured selection time, excluding network transit, so it is\nnot your round trip. **Example values in this document are\nillustrative and are not a performance commitment.**\n","isRequired":true,"uniqueKey":"engine_latency_ms","typeLabel":"number\u003cdouble>"},"policy_version":{"oneOf":[{"type":"string","description":"The frozen version behind the `operating_point` that actually ran.\nRecord it with every result: it is how you detect that you inherited\na default you did not choose.\n","uniqueKey":"policy_version.oneOf.0","typeLabel":"string"},{"type":"null","description":"The frozen version behind the `operating_point` that actually ran.\nRecord it with every result: it is how you detect that you inherited\na default you did not choose.\n","uniqueKey":"policy_version.oneOf.1","typeLabel":"null"}],"uniqueKey":"policy_version","typeLabel":"string | null"},"selected":{"type":"array","default":[],"description":"Per-record detail, in selection order. Empty when you sent\n`return_per_record: false` **and also empty on some stand-downs**, so\nread `records_selected` rather than the array length.\n","items":{"type":"object","required":["record_id"],"description":"One selected record.","properties":{"record_id":{"type":"string","description":"Your `records[].id` when you supplied one; a server-generated id otherwise.","isRequired":true,"uniqueKey":"selected.items.[INDEX].record_id","typeLabel":"string"},"kind":{"type":"string","default":"external_data","uniqueKey":"selected.items.[INDEX].kind","typeLabel":"string"},"title":{"oneOf":[{"type":"string","uniqueKey":"selected.items.[INDEX].title.oneOf.0","typeLabel":"string"},{"type":"null","uniqueKey":"selected.items.[INDEX].title.oneOf.1","typeLabel":"null"}],"uniqueKey":"selected.items.[INDEX].title","typeLabel":"string | null"},"source":{"oneOf":[{"type":"string","uniqueKey":"selected.items.[INDEX].source.oneOf.0","typeLabel":"string"},{"type":"null","uniqueKey":"selected.items.[INDEX].source.oneOf.1","typeLabel":"null"}],"uniqueKey":"selected.items.[INDEX].source","typeLabel":"string | null"},"score":{"type":"number","format":"double","default":0,"description":"Relevance score, comparable **within one response**. Not calibrated\nacross requests or operating points, so rank with it and do not\nthreshold on an absolute value.\n","uniqueKey":"selected.items.[INDEX].score","typeLabel":"number\u003cdouble>"},"reason":{"type":"string","default":"","description":"Why this record was selected. Human-readable and open-ended, so do not exhaustively match it.","uniqueKey":"selected.items.[INDEX].reason","typeLabel":"string"},"excerpt":{"type":"string","default":"","description":"The text that entered the selection. Extractive: built from the\nrecord's own content, never paraphrased or summarised into new\nprose, and no model writes replacement text.\n\n**Not guaranteed byte-identical to a span of your input.** An\nexcerpt may be non-contiguous, may be normalised so whitespace and\nlayout differ from what you sent, may carry a `...[truncated]`\nmarker where content was cut, may carry the\n`[QUARANTINED: instruction-like candidate text removed]` marker where\nsecurity screening removed a flagged span, and may be re-encoded when the\ncontent is structured (see `excerpt_format`).\n\nJoin on `record_id` and use your own copy when you need exact\nbytes. See *Records and tasks*.\n","uniqueKey":"selected.items.[INDEX].excerpt","typeLabel":"string"},"excerpt_format":{"type":"string","default":"plain","description":"The form `excerpt` is in. `plain` is text; other values indicate a\nre-encoding reachable only with `render_format: \"hybrid\"`. Treat this\nas an open set and fall back to handling the value as text.\n","uniqueKey":"selected.items.[INDEX].excerpt_format","typeLabel":"string"},"selected_tokens":{"type":"integer","default":0,"description":"Tokens this record contributed to the selection.","uniqueKey":"selected.items.[INDEX].selected_tokens","typeLabel":"integer"}},"uniqueKey":"selected.items.[INDEX]","typeLabel":"object"},"uniqueKey":"selected","typeLabel":"object[]"},"records_expanded":{"type":"integer","description":"How many extra candidates `budget.autochunk` produced: the candidate\ncount minus the number of records you sent. **Present only on requests\nthat set `budget.autochunk`**, and absent -- not zero -- on every other\nrequest, so that its absence cannot be read as \"autochunk ran and split\nnothing\".\n","uniqueKey":"records_expanded","typeLabel":"integer"},"selection_error":{"oneOf":[{"type":"string","description":"Set when the engine's own selection pass raised. **The HTTP status is\nstill 200** and the body carries a usable full-context result. Alarm\non this field, not on 5xx.\n","uniqueKey":"selection_error.oneOf.0","typeLabel":"string"},{"type":"null","description":"Set when the engine's own selection pass raised. **The HTTP status is\nstill 200** and the body carries a usable full-context result. Alarm\non this field, not on 5xx.\n","uniqueKey":"selection_error.oneOf.1","typeLabel":"null"}],"uniqueKey":"selection_error","typeLabel":"string | null"},"budget_tokens":{"type":"integer","description":"The budget the returned selection was produced under.","uniqueKey":"budget_tokens","typeLabel":"integer"},"attempted_budget_tokens":{"type":"array","items":{"type":"integer","uniqueKey":"attempted_budget_tokens.items.[INDEX]","typeLabel":"integer"},"default":[],"description":"Every rung attempted on the adaptive ladder, in order. Empty on the fixed path. Watch it to see whether an adaptive workload is doing several selection passes per request.","uniqueKey":"attempted_budget_tokens","typeLabel":"integer[]"},"reduction_ratio":{"type":"number","format":"double","description":"`tokens_saved / tokens_before`, on the engine-internal basis. Zero when `tokens_before` is zero.","uniqueKey":"reduction_ratio","typeLabel":"number\u003cdouble>"},"safety":{"oneOf":[{"type":"object","description":"Present on some responses, and **`null` on `np-2026-07-r2`'s\nfixed-budget path**. A null `safety` means the response carries no\nsafety summary, never that the selection was sound.\n","properties":{"selection_safe":{"type":"boolean","default":true,"uniqueKey":"safety.oneOf.0.selection_safe","typeLabel":"boolean"},"fallback_required":{"type":"boolean","default":false,"uniqueKey":"safety.oneOf.0.fallback_required","typeLabel":"boolean"},"fallback_reason":{"type":"string","default":"","description":"The reason carried by this summary. It is not the general stand-down\nreason; see\n`format_metrics.engine_fallback_reason`. This object is absent when\n`safety` is null.\n","uniqueKey":"safety.oneOf.0.fallback_reason","typeLabel":"string"},"coverage_score":{"type":"number","format":"double","default":0,"uniqueKey":"safety.oneOf.0.coverage_score","typeLabel":"number\u003cdouble>"},"evidence_shape":{"type":"string","default":"unknown","uniqueKey":"safety.oneOf.0.evidence_shape","typeLabel":"string"},"evidence_terms":{"oneOf":[{"type":"object","additionalProperties":{"type":"array","items":{"type":"string","uniqueKey":"safety.oneOf.0.evidence_terms.oneOf.0.additionalProperties.items.[INDEX]","typeLabel":"string"},"uniqueKey":"safety.oneOf.0.evidence_terms.oneOf.0.additionalProperties","typeLabel":"string[]"},"uniqueKey":"safety.oneOf.0.evidence_terms.oneOf.0","typeLabel":"object"},{"type":"null","additionalProperties":{"type":"array","items":{"type":"string","uniqueKey":"safety.oneOf.0.evidence_terms.oneOf.1.additionalProperties.items.[INDEX]","typeLabel":"string"},"uniqueKey":"safety.oneOf.0.evidence_terms.oneOf.1.additionalProperties","typeLabel":"string[]"},"uniqueKey":"safety.oneOf.0.evidence_terms.oneOf.1","typeLabel":"null"}],"uniqueKey":"safety.oneOf.0.evidence_terms","typeLabel":"object | null"},"repair_reasons":{"type":"array","items":{"type":"string","uniqueKey":"safety.oneOf.0.repair_reasons.items.[INDEX]","typeLabel":"string"},"default":[],"uniqueKey":"safety.oneOf.0.repair_reasons","typeLabel":"string[]"}},"uniqueKey":"safety.oneOf.0","typeLabel":"object"},{"type":"null","description":"Present on some responses, and **`null` on `np-2026-07-r2`'s\nfixed-budget path**. A null `safety` means the response carries no\nsafety summary, never that the selection was sound.\n","uniqueKey":"safety.oneOf.1","typeLabel":"null"}],"uniqueKey":"safety","typeLabel":"object | null"},"gate":{"oneOf":[{"type":"object","description":"Informational. Not the result of the request; see `outcome`.","properties":{"engaged":{"type":"boolean","default":false,"uniqueKey":"gate.oneOf.0.engaged","typeLabel":"boolean"},"reason":{"type":"string","default":"","examples":["engage:needle","standdown:high_drift"],"uniqueKey":"gate.oneOf.0.reason","typeLabel":"string"},"signals":{"type":"object","additionalProperties":true,"default":{},"description":"JSON-safe observations about this request. Informational, and the\nkey set is **not contractual**: keys may be added or removed, so\nread defensively and do not branch on the absence of one.\n","uniqueKey":"gate.oneOf.0.signals","typeLabel":"object"}},"uniqueKey":"gate.oneOf.0","typeLabel":"object"},{"type":"null","description":"Informational. Not the result of the request; see `outcome`.","uniqueKey":"gate.oneOf.1","typeLabel":"null"}],"uniqueKey":"gate","typeLabel":"object | null"},"format_metrics":{"type":"object","additionalProperties":true,"default":{},"description":"Free-form, additive rendering and diagnostic telemetry. Treat unknown\nkeys as informational. Keys you may see:\n\n- `engine_fallback_reason`: present **only** on a fallback response,\n carrying its own reason.\n- `request_id_sanitized: true`: your `request_id` broke the length\n or charset bound and the internal copy was truncated. Your echo is\n still your bytes.\n- `client_latency_ms`: **added by the published client, not by the\n server.**\n- `security_mode`, `security_action`, `security_findings_count`,\n `security_source_kinds`: present only when security screening ran,\n that is when the request sent a `security_mode` other than `off`, or\n ran on `np-2026-10-r7` or `np-2026-10-r8` without sending `off`.\n The mode that applied; what screening did (`keep`, `audit`,\n `quarantine` or `block`); how many spans were flagged; and the\n provenance kinds of the records it read. See *Errors*.\n","uniqueKey":"format_metrics","typeLabel":"object"},"usage":{"type":"object","description":"The metering receipt for this request. See *How billing works*.","required":["meter_version","outcome","input_tokens","charge_multiplier","price_version","currency"],"properties":{"meter_version":{"type":"string","description":"The definition of a billable unit, including the counting rules.\nImmutable, and **separate from `policy_version`** so that a retune\ncannot reprice anyone and a repricing cannot change a selection.\n","examples":["npm-2026-08-r1"],"isRequired":true,"uniqueKey":"usage.meter_version","typeLabel":"string"},"outcome":{"type":"string","description":"How the request resolved **for pricing**. See the top-level `outcome` for what the engine did; they are separate fields and can legitimately disagree on one response.\n\n**A genuinely open enum, deliberately left unconstrained in this schema so that a generated client cannot reject a valid response.** Do not exhaustively match it. Current values are `engaged`, `escalated`, `stood_down`, `fallback`, `pass_through`, `engine_error`, `empty_input` and `blocked`; new ones ship additively within `/v1`.\n\n`pass_through` means every record came back with the token total and record count both unchanged; the top-level `outcome` legitimately reads `engaged` on the same response. `blocked` is the security screening result of the same name and is charged at `charge_multiplier: \"1.0\"`; a `sanitized_fallback` is priced as `fallback`. Whether a request was charged is carried by `charge_multiplier`. See *How billing works*.\n","examples":["engaged","escalated","stood_down","fallback","pass_through","engine_error","empty_input","blocked"],"isRequired":true,"uniqueKey":"usage.outcome","typeLabel":"string"},"input_tokens":{"type":"integer","description":"The metered input, over every customer-supplied text field the engine\nprocesses. **Always emitted and never zeroed**, including on outcomes\nthat carry no charge; price is carried separately by\n`charge_multiplier`.\n","isRequired":true,"uniqueKey":"usage.input_tokens","typeLabel":"integer"},"charge_multiplier":{"type":"string","description":"Whether this request was charged, as a decimal string to avoid\nbinary-float drift on a monetary quantity: `\"1.0\"` on a request that\nreturned a result, `\"0\"` on one that did not count.\n","examples":["1.0","0"],"isRequired":true,"uniqueKey":"usage.charge_multiplier","typeLabel":"string"},"price_version":{"type":"string","description":"The rate card in force for this request. Separate from `meter_version` for the same reason `meter_version` is separate from `policy_version`.","examples":["npp-2026-10-r1"],"isRequired":true,"uniqueKey":"usage.price_version","typeLabel":"string"},"currency":{"type":"string","examples":["USD"],"isRequired":true,"uniqueKey":"usage.currency","typeLabel":"string"}},"uniqueKey":"usage","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"example":{"request_id":"req-2026-09-03-0001","rendered_context":"Relevant State\n\n1. Credit policy v2 (handbook)\nService credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method.\nCredits require the account owner's written acknowledgement of the cause.\n\n2. user_input\nCustomer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\n\n3. Refund policy v4, section 3 (exceptions) (handbook)\nException: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\n\n4. Refund policy v4, section 2 (handbook)\nRefunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\n\n5. llm_response\nI've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.","policy_version":"np-2026-08-r4","selected":[{"record_id":"r-009","kind":"external_data","title":"Credit policy v2","source":"handbook","score":32.658829095499584,"reason":"hard context: answer-bearing evidence: keyword overlap","excerpt":"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method.\nCredits require the account owner's written acknowledgement of the cause.","excerpt_format":"plain","selected_tokens":76},{"record_id":"r-008","kind":"user_input","title":null,"source":null,"score":54.106697605930485,"reason":"hard context: weighted evidence coverage: current request; keyword overlap; semantic tag overlap","excerpt":"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?","excerpt_format":"plain","selected_tokens":60},{"record_id":"r-005","kind":"external_data","title":"Refund policy v4, section 3 (exceptions)","source":"handbook","score":13.458636537340059,"reason":"hard context: weighted evidence coverage: keyword overlap","excerpt":"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.","excerpt_format":"plain","selected_tokens":67},{"record_id":"r-004","kind":"external_data","title":"Refund policy v4, section 2","source":"handbook","score":14.01558939758398,"reason":"hard context: recent relevant result: keyword overlap","excerpt":"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.","excerpt_format":"plain","selected_tokens":74},{"record_id":"r-021","kind":"llm_response","title":null,"source":null,"score":14.644259731672935,"reason":"soft context: keyword overlap","excerpt":"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.","excerpt_format":"plain","selected_tokens":37}],"tokens_before":1775,"tokens_after":314,"tokens_saved":1461,"records_available":30,"records_selected":5,"fallback_used":false,"selection_error":null,"engine_latency_ms":7.534137000220653,"budget_tokens":900,"attempted_budget_tokens":[900],"reduction_ratio":0.8230985915492958,"safety":{"selection_safe":true,"fallback_required":false,"fallback_reason":"","coverage_score":1,"evidence_shape":"exact_anchor_lookup","evidence_terms":null,"repair_reasons":[]},"gate":{"engaged":true,"reason":"engage:delivered_support_complete","signals":{"n_candidates":21,"high_drift":false}},"format_metrics":{"context_format":"plain","formatted_context_tokens":361,"plain_context_tokens":361,"toon_context_tokens":null,"toon_applied":false,"whole_context_toon_applied":false,"structured_toon_excerpts":0,"structured_toon_tokens_saved":0,"toon_tokens_saved_vs_plain":0,"selection_strategy_used":"fast","selection_strategy_initial":"fast","support_contract_used":"generic","adapter_attempt_count":1,"semantic_adapter_ids":["generic"],"semantic_routing_bounds_hit":false,"semantic_adapter_registry_version":"np-adapters-2026-08-r1","semantic_router_version":"np-router-2026-08-r3","semantic_normalizer_version":"np-normalizer-2026-08-r1","support_contract_resolution_version":"np-support-resolution-2026-08-r3","attempted_recall_rungs":[{"candidate_limit":250,"min_selection_score":8,"max_selected_records":18,"max_selected_tokens":900}]},"selection_strategy_used":"fast","support_contract_used":"generic","adapter_attempt_count":1,"usage":{"meter_version":"npm-2026-08-r1","outcome":"engaged","input_tokens":1998,"charge_multiplier":"1.0","price_version":"npp-2026-10-r1","currency":"USD"},"outcome":"engaged","records_submitted":30,"records_admitted":30,"candidates_truncated":false,"selection_recall":{"version":"npsr-2026-08-r2","operating_point":"np-2026-08-r4","records_submitted":30,"records_admitted":30,"candidate_matches_total":21,"candidates_scored":21,"candidates_above_floor":5,"records_selected":5,"candidate_limit_hit":false,"weighted_term_coverage":0.4838709677419355,"excerpt_term_coverage":0.44086021505376344,"rejection_counts":{"hard_entity_conflict":0,"secret_payload":0,"below_selection_floor":16,"record_count_budget":0,"token_budget":0,"excerpt_coverage_loss":0},"evidence_confidence_score":1,"lexical_coverage":0.44086021505376344},"task_kind":"pointed"},"examples":{"Example":{"title":"Example","value":{"request_id":"req-2026-09-03-0001","rendered_context":"Relevant State\n\n1. Credit policy v2 (handbook)\nService credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method.\nCredits require the account owner's written acknowledgement of the cause.\n\n2. user_input\nCustomer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?\n\n3. Refund policy v4, section 3 (exceptions) (handbook)\nException: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.\n\n4. Refund policy v4, section 2 (handbook)\nRefunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.\n\n5. llm_response\nI've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.","policy_version":"np-2026-08-r4","selected":[{"record_id":"r-009","kind":"external_data","title":"Credit policy v2","source":"handbook","score":32.658829095499584,"reason":"hard context: answer-bearing evidence: keyword overlap","excerpt":"Service credits differ from refunds: credits may be granted for customer-caused overuse at up to 25% of the disputed amount, once per account per year, and are applied to the next invoice rather than returned to the payment method.\nCredits require the account owner's written acknowledgement of the cause.","excerpt_format":"plain","selected_tokens":76},{"record_id":"r-008","kind":"user_input","title":null,"source":null,"score":54.106697605930485,"reason":"hard context: weighted evidence coverage: current request; keyword overlap; semantic tag overlap","excerpt":"Customer (dana@meridiananalytics.com) writes: We were charged $4,320 for July but we believe roughly a third of that usage came from a runaway integration on our side that we shut down on July 19. Can we get a refund or credit for the excess?","excerpt_format":"plain","selected_tokens":60},{"record_id":"r-005","kind":"external_data","title":"Refund policy v4, section 3 (exceptions)","source":"handbook","score":13.458636537340059,"reason":"hard context: weighted evidence coverage: keyword overlap","excerpt":"Exception: accounts in good standing for over 12 months may receive a one-time courtesy refund of up to $500 per calendar year at a support lead's discretion. This exception does not apply to open invoices; the invoice must be paid before a courtesy refund is considered.","excerpt_format":"plain","selected_tokens":67},{"record_id":"r-004","kind":"external_data","title":"Refund policy v4, section 2","source":"handbook","score":14.01558939758398,"reason":"hard context: recent relevant result: keyword overlap","excerpt":"Refunds for metered usage are issued only for platform-caused overcharges verified against receipts. Refunds for subscription line items are prorated to the day of cancellation. All refunds return to the original payment method within 10 business days. Invoices older than 90 days are not eligible.","excerpt_format":"plain","selected_tokens":74},{"record_id":"r-021","kind":"llm_response","title":null,"source":null,"score":14.644259731672935,"reason":"soft context: keyword overlap","excerpt":"I've pulled up account acct_4415 and I'm reviewing the July invoice and usage history now. One moment while I check the key-level traffic breakdown.","excerpt_format":"plain","selected_tokens":37}],"tokens_before":1775,"tokens_after":314,"tokens_saved":1461,"records_available":30,"records_selected":5,"fallback_used":false,"selection_error":null,"engine_latency_ms":7.534137000220653,"budget_tokens":900,"attempted_budget_tokens":[900],"reduction_ratio":0.8230985915492958,"safety":{"selection_safe":true,"fallback_required":false,"fallback_reason":"","coverage_score":1,"evidence_shape":"exact_anchor_lookup","evidence_terms":null,"repair_reasons":[]},"gate":{"engaged":true,"reason":"engage:delivered_support_complete","signals":{"n_candidates":21,"high_drift":false}},"format_metrics":{"context_format":"plain","formatted_context_tokens":361,"plain_context_tokens":361,"toon_context_tokens":null,"toon_applied":false,"whole_context_toon_applied":false,"structured_toon_excerpts":0,"structured_toon_tokens_saved":0,"toon_tokens_saved_vs_plain":0,"selection_strategy_used":"fast","selection_strategy_initial":"fast","support_contract_used":"generic","adapter_attempt_count":1,"semantic_adapter_ids":["generic"],"semantic_routing_bounds_hit":false,"semantic_adapter_registry_version":"np-adapters-2026-08-r1","semantic_router_version":"np-router-2026-08-r3","semantic_normalizer_version":"np-normalizer-2026-08-r1","support_contract_resolution_version":"np-support-resolution-2026-08-r3","attempted_recall_rungs":[{"candidate_limit":250,"min_selection_score":8,"max_selected_records":18,"max_selected_tokens":900}]},"selection_strategy_used":"fast","support_contract_used":"generic","adapter_attempt_count":1,"usage":{"meter_version":"npm-2026-08-r1","outcome":"engaged","input_tokens":1998,"charge_multiplier":"1.0","price_version":"npp-2026-10-r1","currency":"USD"},"outcome":"engaged","records_submitted":30,"records_admitted":30,"candidates_truncated":false,"selection_recall":{"version":"npsr-2026-08-r2","operating_point":"np-2026-08-r4","records_submitted":30,"records_admitted":30,"candidate_matches_total":21,"candidates_scored":21,"candidates_above_floor":5,"records_selected":5,"candidate_limit_hit":false,"weighted_term_coverage":0.4838709677419355,"excerpt_term_coverage":0.44086021505376344,"rejection_counts":{"hard_entity_conflict":0,"secret_payload":0,"below_selection_floor":16,"record_count_budget":0,"token_budget":0,"excerpt_coverage_loss":0},"evidence_confidence_score":1,"lexical_coverage":0.44086021505376344},"task_kind":"pointed"}}},"exampleType":"examples"}},"exampleType":"examples"},"5290fec6-a230-4e8a-8e68-44395f902966":{"description":"Two causes, one status, told apart by whether `reason` is present.\n\n**The body is not a well-formed `ContextRequest`**: malformed JSON, a\nmissing required field, or a field of the wrong type. `detail` is the\nparser's own message about structure and there is **no `reason`**.\n\n**The body parsed and a value in it is not one we serve**: an unknown\n`budget.operating_point`, a `records[].kind` outside the published enum,\na metered text field that is not a string. These carry a `reason`, and\nthey are rejected **before the engine runs**: no `usage` block, no\ncharge.\n\nNeither is retryable. A `400` is a permanent client error and the same\nrequest fails identically every time.\n\n`detail` is returned to you and deliberately **not** written to our logs,\nbecause a type error can quote the offending value, so `detail` may\ncontain a fragment of your own payload. Show it to a developer; think\nbefore you write it to *your* logs.\n","content":{"application/json":{"schema":{"type":"object","required":["error"],"description":"The **service's** error envelope. Distinguishable at a glance from a\ngateway-generated error, which carries a `message`/`Message` key instead\nand never an `error` key. See the individual responses.\n","properties":{"error":{"type":"string","description":"A stable machine-readable code. Match on this, not on `detail`.","enum":["bad_request","payment_required","request_too_large","engine_error","not_found"],"isRequired":true,"uniqueKey":"error","typeLabel":"enum\u003cstring>"},"reason":{"type":"string","description":"A narrower, also stable code, present on a `400` when the body parsed and a\n*value* in it was rejected. **Absent** when the body itself would not\nparse, so read it with a default and never require it. The list below\nis not exhaustive and new reasons ship additively within `/v1`, so a\nclient must tolerate a value it does not recognise.\n","examples":["unknown_operating_point","unknown_record_kind","non_string_text"],"uniqueKey":"reason","typeLabel":"string"},"detail":{"type":"string","description":"Human-readable and **not stable**, so do not parse it.","uniqueKey":"detail","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"malformed":{"title":"malformed","value":{"error":"bad_request","detail":"'task'"}},"unknown_operating_point":{"title":"unknown_operating_point","value":{"error":"bad_request","reason":"unknown_operating_point","detail":"unknown operating_point: 'np-does-not-exist'"}},"unknown_record_kind":{"title":"unknown_record_kind","value":{"error":"bad_request","reason":"unknown_record_kind","detail":"unknown records[].kind: 'not-a-kind'"}},"non_string_text":{"title":"non_string_text","value":{"error":"bad_request","reason":"non_string_text","detail":"records[].text must be a string"}}},"exampleType":"examples"}},"exampleType":"examples"},"8aba5f28-297c-44be-9e10-9ec703667b97":{"description":"**No `Authorization` header at all.** Rejected at the gateway before\nanything of ours is invoked, so the body is the platform's, not ours.\n\nA header that is present but not `Bearer`-shaped is **not** a 401. It\nreaches authorization and comes back `403`. Wire the two separately:\n**401 = the header never arrived** (fix the client), **403 = it arrived\nand was refused** (fix the credential).\n","content":{"application/json":{"schema":{"type":"object","description":"Generated by API Gateway, not by the service. The key is capitalised\ninconsistently between cases (`message` vs `Message`) because these are\nAWS's own bodies passed through unchanged. **Match on the status code,\nnot on this body.**\n","properties":{"message":{"type":"string","uniqueKey":"message","typeLabel":"string"},"Message":{"type":"string","uniqueKey":"Message","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"example":{"message":"Unauthorized"},"examples":{"Example":{"title":"Example","value":{"message":"Unauthorized"}}},"exampleType":"examples"}},"exampleType":"examples"},"3ad080d0-aed5-4c65-a8dc-f92719fe4f2d":{"description":"**Your workspace is out of credit.** It is served, so handle it.\n\nThis is a *service* error, not a gateway one, so it carries the\n`error`/`detail` shape and not the gateway's `message` key.\n\nNothing about the credential is wrong when you see this, which is exactly\nwhy it is a separate status: a `403` says fix the key, a `402` says add\ncredit. Match on the status, or on `error`, and never fold the two\ntogether.\n\n**Do not retry a `402` on a backoff.** It will not clear until credit is\nadded, from the dashboard's Wallet page.\n","content":{"application/json":{"schema":{"type":"object","required":["error"],"description":"The **service's** error envelope. Distinguishable at a glance from a\ngateway-generated error, which carries a `message`/`Message` key instead\nand never an `error` key. See the individual responses.\n","properties":{"error":{"type":"string","description":"A stable machine-readable code. Match on this, not on `detail`.","enum":["bad_request","payment_required","request_too_large","engine_error","not_found"],"isRequired":true,"uniqueKey":"error","typeLabel":"enum\u003cstring>"},"reason":{"type":"string","description":"A narrower, also stable code, present on a `400` when the body parsed and a\n*value* in it was rejected. **Absent** when the body itself would not\nparse, so read it with a default and never require it. The list below\nis not exhaustive and new reasons ship additively within `/v1`, so a\nclient must tolerate a value it does not recognise.\n","examples":["unknown_operating_point","unknown_record_kind","non_string_text"],"uniqueKey":"reason","typeLabel":"string"},"detail":{"type":"string","description":"Human-readable and **not stable**, so do not parse it.","uniqueKey":"detail","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"example":{"error":"payment_required","detail":"This workspace is out of credit. Add credit to resume sending requests."},"examples":{"Example":{"title":"Example","value":{"error":"payment_required","detail":"This workspace is out of credit. Add credit to resume sending requests."}}},"exampleType":"examples"}},"exampleType":"examples"},"7f90e9fc-11fa-469d-b299-e017c3c21672":{"description":"A header arrived and authorization refused it. The reason is deliberately\nnot returned. A caller learns only that the credential does not work,\nbecause an error that distinguishes \"no such key\" from \"suspended org\" is\nan oracle.\n\nCauses: an `Authorization` header that is present but not `Bearer`-shaped;\nan unknown, revoked or malformed key; a suspended org; a control-plane\nprojection too stale to vouch for.\n\nNot retryable. Retrying a 403 will not resolve any of its causes.\n","content":{"application/json":{"schema":{"type":"object","description":"Generated by API Gateway, not by the service. The key is capitalised\ninconsistently between cases (`message` vs `Message`) because these are\nAWS's own bodies passed through unchanged. **Match on the status code,\nnot on this body.**\n","properties":{"message":{"type":"string","uniqueKey":"message","typeLabel":"string"},"Message":{"type":"string","uniqueKey":"Message","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"example":{"Message":"User is not authorized to access this resource with an explicit deny"},"examples":{"Example":{"title":"Example","value":{"Message":"User is not authorized to access this resource with an explicit deny"}}},"exampleType":"examples"}},"exampleType":"examples"},"bcf0f676-0152-4651-833c-d00ea630112d":{"description":"Well-formed, but over a ceiling. **This is the one exact, pre-request cost\ncontrol**. It is checked before the engine runs and before anything is\nbillable.\n\n413 rather than 400 on purpose: your payload is *valid*, so the fix is to\nshrink or split it, not to correct it. `limit_name`, `limit` and\n`observed` tell you which axis and by how much.\n","content":{"application/json":{"schema":{"type":"object","description":"The **service's** error envelope. Distinguishable at a glance from a\ngateway-generated error, which carries a `message`/`Message` key instead\nand never an `error` key. See the individual responses.\n","required":["limit_name","limit","observed","error"],"properties":{"error":{"type":"string","description":"A stable machine-readable code. Match on this, not on `detail`.","enum":["bad_request","payment_required","request_too_large","engine_error","not_found"],"isRequired":true,"uniqueKey":"error","typeLabel":"enum\u003cstring>"},"limit_name":{"type":"string","description":"Which ceiling was exceeded.","enum":["input_tokens","records"],"isRequired":true,"uniqueKey":"limit_name","typeLabel":"enum\u003cstring>"},"limit":{"type":"integer","description":"Your tier's ceiling for that quantity.","isRequired":true,"uniqueKey":"limit","typeLabel":"integer"},"observed":{"type":"integer","description":"What this request measured. The pair is what lets a client resize precisely instead of guessing.","isRequired":true,"uniqueKey":"observed","typeLabel":"integer"},"reason":{"type":"string","description":"A narrower, also stable code, present on a `400` when the body parsed and a\n*value* in it was rejected. **Absent** when the body itself would not\nparse, so read it with a default and never require it. The list below\nis not exhaustive and new reasons ship additively within `/v1`, so a\nclient must tolerate a value it does not recognise.\n","examples":["unknown_operating_point","unknown_record_kind","non_string_text"],"uniqueKey":"reason","typeLabel":"string"},"detail":{"type":"string","description":"Human-readable and **not stable**, so do not parse it.","uniqueKey":"detail","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"example":{"error":"request_too_large","detail":"input_tokens 143820 exceeds the limit of 128000","limit_name":"input_tokens","limit":128000,"observed":143820},"examples":{"Example":{"title":"Example","value":{"error":"request_too_large","detail":"input_tokens 143820 exceeds the limit of 128000","limit_name":"input_tokens","limit":128000,"observed":143820}}},"exampleType":"examples"}},"exampleType":"examples"},"c22eaff2-d95b-4d87-87bf-2cfdd9203a25":{"description":"A usage-plan limit was hit: either the per-second rate/burst, or the\ndaily quota. Both surface as 429 with an AWS body: `Too Many Requests`\nfor throttling, `Limit Exceeded` for the daily quota. **The distinction\nmatters for retry**: a throttle clears in milliseconds, a daily quota\ndoes not clear until the quota period rolls.\n\nRetry throttles with exponential backoff and jitter. Do not retry a\n`Limit Exceeded` in a tight loop.\n\nYour per-minute and per-day figures are **targets, not hard ceilings**.\nSee *Limits* for why, and for what actually is exact.\n","content":{"application/json":{"schema":{"type":"object","description":"Generated by API Gateway, not by the service. The key is capitalised\ninconsistently between cases (`message` vs `Message`) because these are\nAWS's own bodies passed through unchanged. **Match on the status code,\nnot on this body.**\n","properties":{"message":{"type":"string","uniqueKey":"message","typeLabel":"string"},"Message":{"type":"string","uniqueKey":"Message","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"throttled":{"title":"throttled","value":{"message":"Too Many Requests"}},"quota":{"title":"quota","value":{"message":"Limit Exceeded"}}},"exampleType":"examples"}},"exampleType":"examples"},"045bce8b-c42d-4760-9f9f-cf2509e42d47":{"description":"The service could not produce a response at all. The cause is\na transport-level failure, or something inside the service failing before\na body exists.\nNothing a caller can put in a request is *supposed* to reach here: a value\nwe do not serve (an unknown `operating_point`, a record `kind` outside the\npublished enum) is rejected as a **400** before the engine runs.\n\n**Note the asymmetry, because it decides how you monitor us.** A failure\nof the *selection pass itself* does not reach here either: it returns\n**200** with `selection_error` populated and a usable full-context body.\nSo 5xx is not a complete picture of engine health, and `selection_error`\nis the signal to alarm on.\n\nTwo shapes. **`{\"error\": \"engine_error\", …}`** is ours; a body with no\n`error` key is the platform's, produced when something in front of the\nservice fails.\n\nBoth are worth one or two retries with capped exponential backoff, and\nthen stop.\n","content":{"application/json":{"schema":{"type":"object","required":["error"],"description":"The **service's** error envelope. Distinguishable at a glance from a\ngateway-generated error, which carries a `message`/`Message` key instead\nand never an `error` key. See the individual responses.\n","properties":{"error":{"type":"string","description":"A stable machine-readable code. Match on this, not on `detail`.","enum":["bad_request","payment_required","request_too_large","engine_error","not_found"],"isRequired":true,"uniqueKey":"error","typeLabel":"enum\u003cstring>"},"reason":{"type":"string","description":"A narrower, also stable code, present on a `400` when the body parsed and a\n*value* in it was rejected. **Absent** when the body itself would not\nparse, so read it with a default and never require it. The list below\nis not exhaustive and new reasons ship additively within `/v1`, so a\nclient must tolerate a value it does not recognise.\n","examples":["unknown_operating_point","unknown_record_kind","non_string_text"],"uniqueKey":"reason","typeLabel":"string"},"detail":{"type":"string","description":"Human-readable and **not stable**, so do not parse it.","uniqueKey":"detail","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"example":{"error":"engine_error","detail":"RuntimeError: selection pipeline unavailable"},"examples":{"Example":{"title":"Example","value":{"error":"engine_error","detail":"RuntimeError: selection pipeline unavailable"}}},"exampleType":"examples"}},"exampleType":"examples"}},"security":{"65cfa12f-220d-445b-b6a3-dd3043674305":{"bearerAuth":{"type":"http","scheme":"bearer","description":"`Authorization: Bearer np_live_…`\n\nOne credential form. There is no query-parameter, cookie or\n`x-api-key` alternative. The legacy `x-api-key` header stopped being\naccepted at the Bearer cutover and now fails authorization.\n\nKeys are **org-scoped**, never user-scoped, and the secret is shown\nexactly once at mint. Rotation is create-then-revoke.\n","scopes":[],"schemeName":"bearerAuth"}}},"servers":{"8823b6b3-5c44-4637-a982-da3bf24a7ba8":{"url":"https://api.nextmoca.com","description":"Needlepath hosted API."}},"processedSecurityOptions":[{"schemes":[{"scheme":{"type":"http","scheme":"bearer","description":"`Authorization: Bearer np_live_…`\n\nOne credential form. There is no query-parameter, cookie or\n`x-api-key` alternative. The legacy `x-api-key` header stopped being\naccepted at the Bearer cutover and now fails authorization.\n\nKeys are **org-scoped**, never user-scoped, and the secret is shown\nexactly once at mint. Rotation is create-then-revoke.\n","scopes":[],"schemeName":"bearerAuth"},"schema":{"title":"Bearer Auth","type":"string","isRequired":true,"description":"`Authorization: Bearer np_live_…`\n\nOne credential form. There is no query-parameter, cookie or\n`x-api-key` alternative. The legacy `x-api-key` header stopped being\naccepted at the Bearer cutover and now fails authorization.\n\nKeys are **org-scoped**, never user-scoped, and the secret is shown\nexactly once at mint. Rotation is create-then-revoke.\n","format":"bearer","typeLabel":"string\u003cbearer>","deprecated":false},"schemeName":"bearerAuth","name":"Authorization"}],"title":"bearerAuth"}]},"originalFileLocation":"api-reference/openapi.yaml"},"subdomain":"next-moca-global-inc","siteName":"Needlepath","title":"Select the records worth sending to a model - Needlepath","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-26T20:23:28.706Z","originalFileLocation":"api-reference/selection/select-the-records-worth-sending-to-a-model.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Send every record you are considering plus the task they must serve. Needlepath returns the subset it selected, together with a rendered block, per-record scores and reasons, and the token arithmetic. Selection, not rewriting. Nothing is paraphrased or summarised into new prose and no model writes replacement text; an excerpt is built from the record\u0026#x27;s own content. It is not guaranteed byte-identical to a span of your input. See SelectedRecord.excerpt. If you need exact spans, join on record_id and use your own copy. Stateless. Records ride in on every request and nothing is persisted between calls, unless you have asked us in writing to capture your own requests for a review (see Retention and trust). The same request under the same operating_point gets the same answer, with two caveats before you assert on it in a test: that guarantee is scoped to the request exactly as sent, so record order is part of it, and a record sent without an id comes back under a freshly generated one. Send ids, and send a stable order. A stand-down is a success. When Needlepath cannot find evidence that a smaller context covers the task, it stands down and returns your context essentially intact with fallback_used = true: on np-2026-07-r2 as outcome = stood_down with an empty selection, and on np-2026-08-r3, np-2026-08-r4, np-2026-10-r6, np-2026-10-r7 and np-2026-10-r8 as outcome = engaged with every record returned. Treat it as a normal 200 and send what you were going to send, and do not treat a low tokens_saved as an error. Read outcome for this, never gate. Fail open. If this call times out, returns non-2xx, or returns an empty selection, send your original context unmodified. It is a binding rule for every integration, first-party or yours.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Needlepath\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/next-moca-global-inc/F6dagXk1FWIErFSb/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/next-moca-global-inc/F6dagXk1FWIErFSb/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/next-moca-global-inc/F6dagXk1FWIErFSb/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/next-moca-global-inc/F6dagXk1FWIErFSb/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/next-moca-global-inc/F6dagXk1FWIErFSb/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/next-moca-global-inc/F6dagXk1FWIErFSb/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/next-moca-global-inc/F6dagXk1FWIErFSb/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/next-moca-global-inc/F6dagXk1FWIErFSb/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/next-moca-global-inc/F6dagXk1FWIErFSb/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Select the records worth sending to a model - Needlepath\">\u003cmeta data-mint-head property=\"og:description\" content=\"Send every record you are considering plus the task they must serve. Needlepath returns the subset it selected, together with a rendered block, per-record scores and reasons, and the token arithmetic. Selection, not rewriting. Nothing is paraphrased or summarised into new prose and no model writes replacement text; an excerpt is built from the record\u0026#x27;s own content. It is not guaranteed byte-identical to a span of your input. See SelectedRecord.excerpt. If you need exact spans, join on record_id and use your own copy. Stateless. Records ride in on every request and nothing is persisted between calls, unless you have asked us in writing to capture your own requests for a review (see Retention and trust). The same request under the same operating_point gets the same answer, with two caveats before you assert on it in a test: that guarantee is scoped to the request exactly as sent, so record order is part of it, and a record sent without an id comes back under a freshly generated one. Send ids, and send a stable order. A stand-down is a success. When Needlepath cannot find evidence that a smaller context covers the task, it stands down and returns your context essentially intact with fallback_used = true: on np-2026-07-r2 as outcome = stood_down with an empty selection, and on np-2026-08-r3, np-2026-08-r4, np-2026-10-r6, np-2026-10-r7 and np-2026-10-r8 as outcome = engaged with every record returned. Treat it as a normal 200 and send what you were going to send, and do not treat a low tokens_saved as an error. Read outcome for this, never gate. Fail open. If this call times out, returns non-2xx, or returns an empty selection, send your original context unmodified. It is a binding rule for every integration, first-party or yours.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Needlepath\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.nextmoca.com/api-reference/selection/select-the-records-worth-sending-to-a-model\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://next-moca-global-inc.mintlify.app/_mintlify/api/og/v2?division=Selection\u0026amp;title=Select+the+records+worth+sending+to+a+model\u0026amp;description=Send+every+record+you+are+considering+plus+the+task+they+must+serve.%0ANeedlepath+returns+the+subset+it+selected%2C+together+with+a+rendered%0Ablock%2C+per-record+score\u0026amp;theme=8512cbd40a461f9c5b325160\u0026amp;signature=74a9104b2a12757f7b82e3543537ddbcd0d28b40d2b3b1ee32e03218383c33fb\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Select the records worth sending to a model - Needlepath\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Send every record you are considering plus the task they must serve. Needlepath returns the subset it selected, together with a rendered block, per-record scores and reasons, and the token arithmetic. Selection, not rewriting. Nothing is paraphrased or summarised into new prose and no model writes replacement text; an excerpt is built from the record\u0026#x27;s own content. It is not guaranteed byte-identical to a span of your input. See SelectedRecord.excerpt. If you need exact spans, join on record_id and use your own copy. Stateless. Records ride in on every request and nothing is persisted between calls, unless you have asked us in writing to capture your own requests for a review (see Retention and trust). The same request under the same operating_point gets the same answer, with two caveats before you assert on it in a test: that guarantee is scoped to the request exactly as sent, so record order is part of it, and a record sent without an id comes back under a freshly generated one. Send ids, and send a stable order. A stand-down is a success. When Needlepath cannot find evidence that a smaller context covers the task, it stands down and returns your context essentially intact with fallback_used = true: on np-2026-07-r2 as outcome = stood_down with an empty selection, and on np-2026-08-r3, np-2026-08-r4, np-2026-10-r6, np-2026-10-r7 and np-2026-10-r8 as outcome = engaged with every record returned. Treat it as a normal 200 and send what you were going to send, and do not treat a low tokens_saved as an error. Read outcome for this, never gate. Fail open. If this call times out, returns non-2xx, or returns an empty selection, send your original context unmodified. It is a binding rule for every integration, first-party or yours.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://next-moca-global-inc.mintlify.app/_mintlify/api/og/v2?division=Selection\u0026amp;title=Select+the+records+worth+sending+to+a+model\u0026amp;description=Send+every+record+you+are+considering+plus+the+task+they+must+serve.%0ANeedlepath+returns+the+subset+it+selected%2C+together+with+a+rendered%0Ablock%2C+per-record+score\u0026amp;theme=8512cbd40a461f9c5b325160\u0026amp;signature=74a9104b2a12757f7b82e3543537ddbcd0d28b40d2b3b1ee32e03218383c33fb\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/next-moca-global-inc/F6dagXk1FWIErFSb/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Needlepath\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#C97B47\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.nextmoca.com/api-reference/selection/select-the-records-worth-sending-to-a-model\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-reference/selection/select-the-records-worth-sending-to-a-model.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.nextmoca.com/#organization\",\"name\":\"Needlepath\",\"url\":\"https://docs.nextmoca.com\"},{\"@type\":\"WebSite\",\"@id\":\"https://docs.nextmoca.com#website\",\"name\":\"Needlepath\",\"url\":\"https://docs.nextmoca.com\",\"publisher\":{\"@id\":\"https://docs.nextmoca.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.nextmoca.com/api-reference/selection/select-the-records-worth-sending-to-a-model#webpage\",\"url\":\"https://docs.nextmoca.com/api-reference/selection/select-the-records-worth-sending-to-a-model\",\"name\":\"Select the records worth sending to a model\",\"description\":\"Send every record you are considering plus the task they must serve. Needlepath returns the subset it selected, together with a rendered block, per-record scores and reasons, and the token arithmetic. Selection, not rewriting. Nothing is paraphrased or summarised into new prose and no model writes replacement text; an excerpt is built from the record's own content. It is not guaranteed byte-identical to a span of your input. See SelectedRecord.excerpt. If you need exact spans, join on record_id and use your own copy. Stateless. Records ride in on every request and nothing is persisted between calls, unless you have asked us in writing to capture your own requests for a review (see Retention and trust). The same request under the same operating_point gets the same answer, with two caveats before you assert on it in a test: that guarantee is scoped to the request exactly as sent, so record order is part of it, and a record sent without an id comes back under a freshly generated one. Send ids, and send a stable order. A stand-down is a success. When Needlepath cannot find evidence that a smaller context covers the task, it stands down and returns your context essentially intact with fallback_used = true: on np-2026-07-r2 as outcome = stood_down with an empty selection, and on np-2026-08-r3, np-2026-08-r4, np-2026-10-r6, np-2026-10-r7 and np-2026-10-r8 as outcome = engaged with every record returned. Treat it as a normal 200 and send what you were going to send, and do not treat a low tokens_saved as an error. Read outcome for this, never gate. Fail open. If this call times out, returns non-2xx, or returns an empty selection, send your original context unmodified. It is a binding rule for every integration, first-party or yours.\",\"dateModified\":\"2026-10-26T20:23:28.706Z\",\"isPartOf\":{\"@id\":\"https://docs.nextmoca.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.nextmoca.com/api-reference/selection/select-the-records-worth-sending-to-a-model#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.nextmoca.com/api-reference/selection/select-the-records-worth-sending-to-a-model#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Needlepath\",\"item\":\"https://docs.nextmoca.com\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Select the records worth sending to a model\",\"item\":\"https://docs.nextmoca.com/api-reference/selection/select-the-records-worth-sending-to-a-model\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.nextmoca.com/api-reference/selection/select-the-records-worth-sending-to-a-model#apireference\",\"headline\":\"Select the records worth sending to a model\",\"name\":\"Select the records worth sending to a model\",\"description\":\"Send every record you are considering plus the task they must serve. Needlepath returns the subset it selected, together with a rendered block, per-record scores and reasons, and the token arithmetic. Selection, not rewriting. Nothing is paraphrased or summarised into new prose and no model writes replacement text; an excerpt is built from the record's own content. It is not guaranteed byte-identical to a span of your input. See SelectedRecord.excerpt. If you need exact spans, join on record_id and use your own copy. Stateless. Records ride in on every request and nothing is persisted between calls, unless you have asked us in writing to capture your own requests for a review (see Retention and trust). The same request under the same operating_point gets the same answer, with two caveats before you assert on it in a test: that guarantee is scoped to the request exactly as sent, so record order is part of it, and a record sent without an id comes back under a freshly generated one. Send ids, and send a stable order. A stand-down is a success. When Needlepath cannot find evidence that a smaller context covers the task, it stands down and returns your context essentially intact with fallback_used = true: on np-2026-07-r2 as outcome = stood_down with an empty selection, and on np-2026-08-r3, np-2026-08-r4, np-2026-10-r6, np-2026-10-r7 and np-2026-10-r8 as outcome = engaged with every record returned. Treat it as a normal 200 and send what you were going to send, and do not treat a low tokens_saved as an error. Read outcome for this, never gate. Fail open. If this call times out, returns non-2xx, or returns an empty selection, send your original context unmodified. It is a binding rule for every integration, first-party or yours.\",\"url\":\"https://docs.nextmoca.com/api-reference/selection/select-the-records-worth-sending-to-a-model\",\"mainEntityOfPage\":{\"@id\":\"https://docs.nextmoca.com/api-reference/selection/select-the-records-worth-sending-to-a-model#webpage\"},\"dateModified\":\"2026-10-26T20:23:28.706Z\",\"publisher\":{\"@id\":\"https://docs.nextmoca.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.nextmoca.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Needlepath\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Needlepath","nav":{"global":null,"tabs":[{"tab":"Documentation","pages":[{"title":"Documentation","href":""}]},{"tab":"API reference","groups":[{"group":"Overview","pages":[{"title":"API reference","sidebarTitle":"Overview","description":"Three endpoints, one credential, and the two client rules that keep an integration working across additive changes.","href":"/api-reference/introduction"}]},{"group":"Endpoints","pages":[{"group":"Selection","pages":[{"title":"Select the records worth sending to a model","deprecated":null,"version":null,"openapi":"/api-reference/openapi.yaml post /v1/context/select","href":"/api-reference/selection/select-the-records-worth-sending-to-a-model"}]},{"group":"Registry","pages":[{"title":"The public registry of immutable operating-point labels","description":"Every label this deployment can resolve, and the frozen `policy_version`\nbehind each. Only the label and its version cross the wire; the\nconfiguration behind a label is not\ndisclosed, so published results are **verifiable** and **re-runnable**\nbut **not inspectable**.\n\nA label pins a configuration, not an engine build. See\n*Operating points*.\n","deprecated":null,"version":null,"openapi":"/api-reference/openapi.yaml get /v1/operating-points","href":"/api-reference/registry/the-public-registry-of-immutable-operating-point-labels"},{"title":"Liveness, and the label this build serves by default","deprecated":null,"version":null,"openapi":"/api-reference/openapi.yaml get /v1/health","href":"/api-reference/registry/liveness-and-the-label-this-build-serves-by-default"}]}]}]}]},"basePath":"","title":"Select the records worth sending to a model - Needlepath","buildId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","deploymentId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","dynamics":["c2aa737661","2b790eda92","b0f84f53ff","a9bb46feb3"],"chunks":["OpenApiReferenceProvider-CS552b7R.js","utils-DDTCYAF2.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-De8ttokP.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema-DrwRDvAh.js","snippetPresets-DtAN0nWx.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","ApiExamples-D5rWArI6.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-O2i12wsz.js","shallow-DV8xABTt.js","getApiPlaygroundDisplay-DBZ0B5Jx.js","CodeSnippet-BVi0tPUX.js","CodeSnippets-CqASbIwY.js","Page-m07pfKpT.js","getPastedJson-DG9vsMS8.js","icon-CXzRSCr8.js","MethodPill-BdKVtEuX.js","DuplicateIcon-CZlmBrJI.js","createIcon-biFEUKPL.js","DynamicMarkdown-B54_zNBF.js","SectionHeading-DwwHK3Pt.js","axios-vUo_bRtp.js","Markdown-DfhCTwyA.js","clsx-xpJZXxdP.js","lib-DuNMoZ05.js","lib-B8HbPgcC.js","html-void-elements-mCSPHezU.js","dist-BTZUMDnx.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js","AssistantPageLink-DqdKa2R4.js"]}