Skip to main content

Configure an app with a coding assistant

Copy this prompt into any new session​

Copy the entire prompt below. It already includes the guide URL.

Read and follow the full guide:
https://www.agentdatamcp.com/docs/agentdispatcher/integration-guide.md
If unavailable, ask for its Markdown; do not guess.

Audit this repository before changing it. Read docs/dispatcher-integration.md
first if present, then inspect code, YAML and deployment configuration for every
service, LLM path and job: interactive calls, embeddings, image generation, streaming, agents,
helpers, retries, schedulers and queue workers.

Fix only confirmed gaps. Reuse existing connections, credentials, variables,
helpers, feature/sub-feature names and job names. Do not duplicate or rotate keys,
add parallel wrappers/reporters, or recreate existing schedules. If already
correctly configured, verify and report it; leave working code/config unchanged.
Preserve models, prompts, scheduling and application behavior.

Use the gateway for LLM accounting and the guide's HTTP job lifecycle through
one shared runner/client; no Dispatcher SDK. Reuse the existing reporting key
(DISPATCHER_SDK_KEY is its legacy name); use DISPATCHER_REPORTING_KEY only for a
new configuration. It is separate from the LLM key. Follow the guide's URL,
retry, heartbeat, cancellation and context-propagation rules. Do not add
application/environment or schedule-ID variables. Add missed-run detection only
if requested. Never double-report a job or gateway charge.

Verify with mocks, including repeat setup and concurrent jobs, then a small
authorized live call/job. Check the deployed revision and actual Dispatcher
records when access permits; code or variables alone are not live verification.
Never print or commit secrets. Missing access must not prevent code/templates.

Update docs/dispatcher-integration.md and return the Configuration and verification
report specified below: every service/path, exact non-secret settings, credential
presence/source, test evidence, and each gap with precise setup and retest steps.
Distinguish code implementation, deployed configuration and live verification.
Use verified, implemented but untested, blocked, or intentionally excluded with
reasons; do not claim everything works while required checks remain unverified.
Future sessions must reuse and update this map.

This prompt works for any application, including AgentDesk. The session must inspect that application's repository to identify its actual features and jobs. Dispatcher cannot infer a call's business purpose automatically.

The sections below explain the integration contract and provide examples for the session.

Already configured? Copy this verification prompt​

Use this after setup or deployment, including in your existing AgentDesk session. It checks the integration without creating another connection or reporting path.

Read and follow https://www.agentdatamcp.com/docs/agentdispatcher/integration-guide.md
If unavailable, ask for its Markdown; do not guess.

Verify this application's existing Dispatcher integration. Read
docs/dispatcher-integration.md first, then inspect every service, LLM path and
job in code, YAML and deployment configuration. Follow the guide's audit and
Configuration and verification report requirements. Do not change working
code/configuration, rotate/create keys, add wrappers or recreate schedules.

Check what is implemented, what the deployed services actually use, and what
Dispatcher receives. Validate gateway routing, feature/sub-feature labels,
reporting-key scope, job start/finish/heartbeat and LLM/run correlation.
Use mocks for retries, concurrency, failure/cancellation and reporting outages;
then a small authorized live call/job through the application's actual path.
Do not run destructive jobs or create production failures to test reporting.
If live testing is unavailable, state the exact blocker and leave it unverified.

Return the report with per-service non-secret settings, secret presence/source,
evidence and precise steps to fix and retest each gap. Never reveal secrets.
Do not infer success from a variable, successful HTTP request or mock alone.
Update the saved map with evidence, date and deployed revision. Explain whether
it is fully verified, partly verified or blocked; do not silently repair gaps.

Configuration and verification report​

Both prompts must produce this report in the session reply and save the relevant facts in docs/dispatcher-integration.md. Keep the report specific to the inspected application. A recommended value is not proof that it is configured.

  1. Result and changes. State fully verified, partly verified or blocked, the application/environment, inspected revision and deployed revision (or unknown). Summarize changes and reused connections/helpers. Fully verified means every required path has the evidence below; justified exclusions stay visible.

  2. Coverage map. Include every discovered service/path, not just one sample:

    ServiceEntry point/fileProvider/SDKFeatureSub-featureJob/scheduleRequired variablesStatus and evidence

    Use verified, implemented but untested, blocked, or intentionally excluded, with a reason per row. Record code findings, deployment checks, mock results and live results separately. A sample live call does not verify other models, services, embeddings or streaming paths.

  3. Configuration per service. List the variable/config field, where it is read (file or constructor), effective non-secret value, deployment location and state: confirmed, missing or unknown. For secrets show only present/missing/unknown, credential purpose and source (for example, the existing AgentDesk reporting key). Never show secret values or dumps of environment variables. Include explicit client overrides and whether a redeploy/restart is still needed. Reuse existing names; do not add variables merely to populate this table.

  4. Verification evidence. Give the check, time, environment/revision and outcome. For live LLM usage, identify the new Dispatcher record and verify its application, provider/model and feature/sub-feature. For a job, verify its run ID, terminal state, heartbeat where applicable, and correlated LLM records. Verify one run per execution and no duplicate charge reporting. Use synthetic input, existing authorized access and a safe application path. An isolated HTTP reporting test verifies the endpoint, not that the real scheduler invokes the shared runner. If Dispatcher records cannot be inspected, explicitly leave ingestion unverified.

  5. Remaining actions. For every missing or unverified item, give: service → gap → exact change/location → who can do it → retest → expected result. Provide copyable non-secret assignments or code changes where useful. For a missing secret, explain the UI path to reuse/create the correct credential and where to store it; use a clearly marked placeholder, never a real key. Distinguish a confirmed missing setting from one that cannot be inspected. If nothing is missing, say so and cite the checks rather than making an unsupported claim.

AgentDesk example: what the report must establish​

If the repository contains exp1 and AgentDesk_Scheduler, report them separately using their actual deployed names. Confirm that each uses the existing Dispatcher LLM URL/key and that its running code reads the configured reporting-key variable (DISPATCHER_REPORTING_KEY or the existing legacy name). Confirm both credentials have the intended application/environment scope when access permits.

A reporting key being present in Railway does not prove jobs are reported. Check each scheduler's invocation of the shared runner, feature/sub-feature propagation, and an actual completed run in Job runs. Confirm its LLM activity under Overview, filtering by the application and relevant feature. A service without jobs needs no job instrumentation; explain that exclusion from code evidence. If implementation and configuration were checked but no live run was observed, report implemented but untested, not verified. If code or deployment access is missing, identify that verification blocker. Never trigger a real business job without authorization.

For a missing reporting credential, the actionable instruction is: Applications → Application LLM calls → the existing connection → Configure → Job reporting. Reuse the saved reporting secret. If no reporting key exists, create one and use Copy configuration. In Railway, select the correct project/environment/service → Variables, set that service's existing reporting variable (or DISPATCHER_REPORTING_KEY for new configuration), then deploy/restart as required. Do not replace OPENAI_API_KEY or ANTHROPIC_API_KEY with it. If a key exists but its secret is unavailable, report that blocker; do not silently rotate it.

Before changing an existing integration​

The saved app map is the starting point, not proof that the deployed app works. Check actual client constructors, shared wrappers, dependency registrations, YAML, environment-variable references and deployment overrides. Record what is already working, what is missing and what cannot yet be verified.

  • Reuse the same connection and reporting key for the same application/environment. Confirm their scope when access allows; do not reuse one application's identity for a different app. Never create or rotate credentials just because this audit is repeated. Existing custom variable names can stay if mapped correctly.
  • Instrument each LLM request path and job execution once. Check nested decorators, scheduler hooks, queue middleware, callbacks and old SDK wrappers before adding anything. Update the existing shared helper instead of layering another reporter.
  • Keep feature names stable. Add labels only for uncovered operations, merging metadata without dropping existing request options. Carry job context through async/queue boundaries without process-global state that mixes concurrent jobs.
  • Retry a start report with the same execution's idempotency key. A new execution gets a new identity. Do not collapse genuinely billed LLM retries into one charge; avoid adding a second charge event for the same gateway request instead.
  • Do not recreate Dispatcher connections or missed-run schedules on application startup. Configure missed-run detection only when requested, after checking for the existing application/environment/job-name entry.
  • Verify a second setup pass makes no additional configuration or instrumentation changes. Mock duplicate start retries, concurrent job context, completion, failure/cancellation and reporting outages. Confirm one job run per execution and no added billable events for gateway calls.

If everything is already correct, make no code or configuration changes. Update the saved map only with new verification evidence or corrected facts. Record the test/check, date, revision/environment and outcome without secrets; distinguish mocked checks from live verification. Missing live access remains implemented but untested or blocked, never a claim of verified deployment.

1. Supply the connection settings​

Create an LLM connection under Applications → Application LLM calls. Configure real provider credentials under Settings → LLM providers. The application uses the Dispatcher connection key, not the provider key or gateway master key.

# Set only the SDK variables used by this service. Both SDKs can share this URL.
OPENAI_BASE_URL=https://YOUR-DISPATCHER-HOST/llm
OPENAI_API_KEY=YOUR-DISPATCHER-CONNECTION-KEY
ANTHROPIC_BASE_URL=https://YOUR-DISPATCHER-HOST/llm
ANTHROPIC_API_KEY=YOUR-DISPATCHER-CONNECTION-KEY
DISPATCHER_FEATURE=backend

The URL is the backend's /llm route. Existing OpenAI /llm/v1 configurations also work; do not add /v1 to Anthropic's base URL. Explicit client constructor settings may override environment variables, so the session must inspect them too.

Keep the app's model configuration. A configured connection default can override it. Grok, Gemini and DeepSeek can use the OpenAI-compatible gateway route; do not assume changing the URL of their native SDKs is sufficient. List unsupported paths explicitly. The connection key identifies the application; project and api_id are not required for ordinary LLM attribution. Use separate connections for different apps/environments.

For image generation, use the same connection and POST /llm/v1/images/generations with an image-capable OpenAI, Gemini/Imagen or FLUX model. Reuse the OpenAI-compatible images client and feature/sub-feature context; do not redirect native Google SDKs blindly or force a chat default onto image requests. See the provider and image setup.

2. Choose stable feature names​

Use feature = area of work, sub-feature = operation. Use short lowercase names such as backend.embedding; the first dot separates feature from sub-feature. Do not put user emails, document names, run IDs, prompts or secrets in these labels. Do not rename existing labels unless a reporting change is intended.

Suggested AgentDesk mappings — keep only operations found in the repository:

Work found in the codeFeatureSub-feature
Interactive assistant responseassistantresponse
Backend embeddingsbackendembedding
Memory extractionmemoryextract
Scheduled memory refreshschedulermemory_refresh
Scheduled summarizationschedulersummary
Work-item implementation/reviewwork_itemimplement / review

A process can execute many features. Precedence should be explicit call/task labels → operation-specific YAML labels → service fallback (DISPATCHER_FEATURE). For example, a scheduler service's default is scheduler, but each job supplies its own sub-feature. An environment variable alone does not transmit metadata.

Add this keyword to an existing OpenAI call, using values from your shared helper:

extra_body={"metadata": {"dispatcher_context": {"feature": "backend", "sub_feature": "embedding"}}},

For the native Anthropic SDK, use:

extra_body={"litellm_metadata": {"dispatcher_context": {"feature": "assistant", "sub_feature": "response"}}},

Merge with existing extra_body and metadata; do not overwrite unrelated options. Apply the same context to embeddings and streaming paths where supported, and test those paths separately. User attribution requires the app to supply a stable user ID; an app key does not identify the individual user.

Example operation-specific YAML, loaded by your app:

jobs:
memory_refresh:
name: memory-refresh
usage:
feature: scheduler
sub_feature: memory_refresh

The helper reads jobs.memory_refresh.usage and attaches it to the LLM call. Dispatcher does not read your local YAML or automatically attach its labels.

3. Report jobs with HTTP — no Dispatcher SDK​

LLM requests sent through the gateway already report tokens and costs, including scheduled LLM calls. No reporting key or extra integration is needed for that. To also see whether the whole job starts, succeeds or fails, connect your existing job runner once using its HTTP client. This works with Node, Go, Rust, C#, Python and other languages; there is no Dispatcher package or Python requirement for callers.

Configure once​

An owner/admin opens Applications → Application LLM calls, finds the application's connection and selects Configure → Job reporting. This opens a dialog in place. The application and environment come from the selected connection; no retyping is needed.

  • If an active reporting key is listed, reuse its secret from the application's deployment settings. The saved key shows only its last four characters; the full secret cannot be retrieved.
  • Otherwise, select Create reporting key, then Copy API key and save it in your deployment secret store. It is shown only at creation. The generated-key panel also shows the exact DISPATCHER_REPORTING_KEY=... assignment: use Copy configuration to copy it with the real key. Show/Hide applies to both the key and configuration; copying still uses the full value when masked. The job-start endpoint is shown separately, resolved from the Dispatcher URL. No extra application, environment, schedule-ID or URL variable is needed when the existing URL is available.
  • If the existing secret is lost, open that reporting key's Edit dialog and choose Recreate key. Confirm, copy the new secret and update every reporting service. The old secret stops working immediately; the same connection scope and job history remain.
  • Edit names and limits with the single Save button beside Close. Save activates only after a change; Close/Escape asks before discarding unsaved edits.
  • Use the same reporting key in every service reporting jobs for that application and environment. For example, AgentDesk's exp1 and AgentDesk_Scheduler can share it when both use the same application/environment. Do not create one key per scheduler.

The reporting key is separate from the LLM connection key and cannot be used for billable LLM requests. Keep your existing OPENAI_API_KEY / ANTHROPIC_API_KEY values. Applications without an LLM connection can manage reporting keys under Applications → Other API usage → Reporting connections.

DISPATCHER_REPORTING_KEY=YOUR-REPORTING-KEY

DISPATCHER_SDK_KEY is the old environment-variable name for this same credential. An existing app can continue reading that variable; do not create a second key. Variable names are your app's configuration convention, not HTTP protocol fields.

Reuse the existing Dispatcher gateway host, removing only the final /llm or /llm/v1 path suffix. For example, a gateway at https://YOUR-HOST/llm reports jobs at https://YOUR-HOST/api/jobs/start. Preserve deployment path prefixes. If your OpenAI and Anthropic settings point to different backends or direct providers, choose the Dispatcher backend explicitly. Reuse existing YAML settings; no duplicate URL, application or environment variables are necessary.

Start and finish​

These are HTTP requests, usable from any language. Substitute your reporting key.

POST /api/jobs/start
Authorization: Bearer YOUR-REPORTING-KEY
Content-Type: application/json
Idempotency-Key: UNIQUE-SCHEDULER-EXECUTION-ID

{"name":"memory-refresh"}

Dispatcher returns HTTP 201, creates the run ID and timestamps, and derives application/environment from the authenticated key:

{
"run_id": "SERVER-GENERATED-UUID",
"state": "running",
"dispatcher_context": {
"job_run_id": "SERVER-GENERATED-UUID",
"trace_id": "SERVER-GENERATED-TRACE-ID"
}
}

Keep run_id in the job's execution context and finish with HTTP 200:

POST /api/jobs/SERVER-GENERATED-UUID/finish
Authorization: Bearer YOUR-REPORTING-KEY
Content-Type: application/json

{"state":"completed"}

Send failed if the job raises an error, or cancelled if cancelled. Preserve the original return value/error. Each real execution has its own run; do not use a single run ID for every invocation of the same job. No registration is needed for ordinary jobs: their first start report appears in Job runs.

For long-running jobs, send the following about once a minute while running:

POST /api/jobs/SERVER-GENERATED-UUID/heartbeat
Authorization: Bearer YOUR-REPORTING-KEY

No body is needed. Heartbeats return 200 and indicate liveness, not business progress. Your runner owns this timer; it is not automatic with HTTP. Stop and await in-flight heartbeats before sending the final outcome. Reuse the same reporting key throughout the run. A stopped process cannot send a final event, so Dispatcher marks it stale after the configured heartbeat timeout.

Integrate one shared runner​

The implementation follows this sequence using the application's existing HTTP client:

start = report start(job.name, idempotency_key=job.execution_id)
start heartbeat timer if start succeeded and the job is long-running
try:
result = await existing_job() # Use the existing sync/async execution model.
outcome = completed
catch cancellation:
outcome = cancelled; preserve cancellation
catch error:
outcome = failed; preserve original error
finally:
stop and await heartbeat timer
if start succeeded: report finish(start.run_id, outcome)
return the original result or re-raise the original error

Use bounded HTTP timeouts and log reporting failures without keys, prompts or business payloads. Reporting failures must not replace business results/errors. Do not send a finish request if start failed and no run ID is known; report that coverage gap.

The optional Idempotency-Key header makes start retries safe: reuse the existing scheduler/queue execution ID for retries of that start request. Reusing it with a different name or expected occurrence returns 409. Without this header every start creates a new run, so do not blindly retry after a lost response. A replay returns the stored run and its current state; it never restarts the job. Finishing repeatedly with the same outcome is safe. Changing a finished outcome or heartbeating a finished run returns 409. Unknown runs and runs owned by another key return 404; invalid or revoked keys return 401. Do not keep retrying validation/authentication failures.

Merge the returned dispatcher_context with existing feature/sub-feature metadata and attach it to the job's LLM calls. For example, in Node using an existing OpenAI client:

const dispatcherContext = {
...start.dispatcher_context,
feature: job.usage.feature,
sub_feature: job.usage.sub_feature,
};
await client.chat.completions.create({
...existingRequest,
metadata: { ...existingRequest.metadata, dispatcher_context: dispatcherContext },
});

For the OpenAI Responses API, put the same context in litellm_metadata using the SDK's extra-body option (Python example):

response = client.responses.create(
**existing_request,
extra_body={"litellm_metadata": {"dispatcher_context": dispatcher_context}},
)

Merge this with any existing extra-body options. Existing metadata.dispatcher_context is also accepted; do not send conflicting context in both places.

For native Anthropic use litellm_metadata as shown in section 2. The names and placement of extra-body options depend on the provider SDK/language; preserve existing options and verify the actual outbound request. Do not record an additional billable event for the gateway call. Correlation requires sending this context; Dispatcher cannot associate concurrent calls with a job just from its application key.

4. Optional: detect jobs that never start​

An administrator opens Job runs → Monitor a scheduled job and configures the application/environment, exact reported job name, cadence, timezone, first expected occurrence and grace period. IDs stay internal; no schedule-ID variable belongs in application configuration. Saving the same app/environment/job name updates its schedule.

Add only the scheduler's intended occurrence to the start request:

{"name":"memory-refresh","scheduled_for":"2026-11-17T09:00:00Z"}

The timestamp above is an example, not a value to copy into every run. Use the actual intended start, including timezone, even if execution starts late. Fixed intervals, daily and monthly schedules are supported; arbitrary cron is not. If timing cannot be represented accurately or the scheduler cannot supply the intended occurrence, keep ordinary job reporting. Never change the real scheduler to fit monitoring. Unknown or ambiguous names and invalid occurrence times return 422.

Existing integrations​

The former monitoring SDK has been removed from this repository. Existing installed SDK clients can still use /api/jobs/events during migration; that detailed protocol and ingestion endpoints remain supported. Migrate one shared runner at a time, verify a success/failure/heartbeat, then remove the SDK dependency and wrappers from that app. Do not run both integrations for the same job. The CLI Collector is a separate component and does not need replacing for this change.

5. Verify and leave a handoff​

Use the Configuration and verification report above; retain evidence per path.

  • In Overview, confirm the app, provider/model, Feature and Sub-feature on a new call.
  • In Job runs, confirm an authorized successful test run and heartbeats where applicable. Verify failure/cancellation with mocks; live failure tests require an authorized safe test job.
  • If missed-run detection is enabled, test a missed occurrence with a dedicated test schedule, then disable it.
  • Confirm the job's LLM requests carry its run ID and charges are counted once.
  • List missing instrumentation explicitly; never claim coverage of untested services.
  • Save the service/feature/schedule map and required variable names in docs/dispatcher-integration.md in the consuming app. Future sessions update this file instead of inventing a new naming scheme. Never save credential values there.

For provider setup and full client examples, see the general quick start.