Skip to main content

runOneShotAgent

@nmi-agro/fdm-source


@nmi-agro/fdm-source / fdm-agents/src / runOneShotAgent

Function: runOneShotAgent()

runOneShotAgent(agent, input, context?, posthog?, timeoutMs?, recursionLimit?): Promise<OneShotAgentResult>

Defined in: fdm-agents/src/runners/one-shot.ts:92

Common runner for one-shot agent execution in fdm-agents.

Parameters

agent

AgentGraph

The compiled LangGraph agent to run.

input

string

The user input string.

context?

Record<string, any> = {}

Extra context to provide via config.configurable (e.g. principalId, nmiApiKey).

posthog?

Optional PostHog client and distinctId for tracking.

client

any

distinctId

string

timeoutMs?

number = ...

Maximum milliseconds to wait for the agent to complete (default: 20 minutes). Throws AgentTimeoutError on expiry.

recursionLimit?

number = 100

Maximum number of graph steps before LangGraph aborts (default: 100). Each LLM↔tool round-trip is ~2 steps.

Returns

Promise<OneShotAgentResult>

The final response and token usage from the agent.