Package com.tnsai.timeout
Record Class TimeoutPolicy
java.lang.Object
java.lang.Record
com.tnsai.timeout.TimeoutPolicy
- Record Components:
llmCall- ceiling for an LLM chat / streaming calltoolCall- ceiling for a single tool dispatchmcpCall- ceiling for an MCP request to an external serverchannelSend- ceiling for a single channel adapter send
public record TimeoutPolicy(Duration llmCall, Duration toolCall, Duration mcpCall, Duration channelSend)
extends Record
Framework-level timeout configuration for the four call categories
the framework can issue (issue #16). Centralises what was previously
scattered across modules (the LLM client, MCP transport, Telegram
adapter, individual tools).
Duration.ZERO means unbounded for that category —
the call may run indefinitely. Negative durations are rejected.
Foundation slice: this PR ships the type. Integration into
AgentBuilder.timeoutPolicy(), the LLM call path, MCP
stdio transport, and channel send wraps lands as separate
follow-ups so each integration ships with its own dedicated tests.
- Since:
- 0.5.0 (issue #16)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic enumThe four call categories the framework times. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTimeoutPolicy(Duration llmCall, Duration toolCall, Duration mcpCall, Duration channelSend) Creates an instance of aTimeoutPolicyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic TimeoutPolicy.Builderbuilder()Returns the value of thechannelSendrecord component.static TimeoutPolicydefaults()Sensible defaults rooted in observed production behaviour: LLM 60s (long generations), tool 30s (matchesTool.getTimeout()default from #18), MCP 15s (interactive snappiness), channel 10s (rate-limited backoff happens above this).final booleanIndicates whether some other object is "equal to" this one.get(TimeoutPolicy.Category category) Generic accessor for the duration of a given category.final inthashCode()Returns a hash code value for this object.booleanisUnbounded(TimeoutPolicy.Category category) Whether the given category is unbounded under this policy.llmCall()Returns the value of thellmCallrecord component.mcpCall()Returns the value of themcpCallrecord component.Returns a builder pre-populated with this policy's values.toolCall()Returns the value of thetoolCallrecord component.final StringtoString()Returns a string representation of this record class.static TimeoutPolicyEvery category is unbounded.
-
Field Details
-
UNBOUNDED
Sentinel for "no timeout" — call may run indefinitely.
-
-
Constructor Details
-
TimeoutPolicy
Creates an instance of aTimeoutPolicyrecord class.- Parameters:
llmCall- the value for thellmCallrecord componenttoolCall- the value for thetoolCallrecord componentmcpCall- the value for themcpCallrecord componentchannelSend- the value for thechannelSendrecord component
-
-
Method Details
-
defaults
Sensible defaults rooted in observed production behaviour: LLM 60s (long generations), tool 30s (matchesTool.getTimeout()default from #18), MCP 15s (interactive snappiness), channel 10s (rate-limited backoff happens above this). -
unbounded
Every category is unbounded. Useful for batch / overnight workflows where wall-clock cost is irrelevant. -
builder
-
toBuilder
Returns a builder pre-populated with this policy's values. -
isUnbounded
Whether the given category is unbounded under this policy. -
get
Generic accessor for the duration of a given category. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
llmCall
Returns the value of thellmCallrecord component.- Returns:
- the value of the
llmCallrecord component
-
toolCall
Returns the value of thetoolCallrecord component.- Returns:
- the value of the
toolCallrecord component
-
mcpCall
Returns the value of themcpCallrecord component.- Returns:
- the value of the
mcpCallrecord component
-
channelSend
Returns the value of thechannelSendrecord component.- Returns:
- the value of the
channelSendrecord component
-