ReplanRequestedException

class ReplanRequestedException constructor(val reason: String, val blackboardUpdater: BlackboardUpdater = BlackboardUpdater {}) : RuntimeException

Exception thrown by a tool to signal that the tool loop should terminate and the agent should replan based on the updated blackboard state.

This enables tools to influence agent behavior at a higher level than just returning results. Use cases include:

  • Chat routing: A routing tool classifies user intent and requests replan to switch to the appropriate handler action

  • Discovery: A tool discovers that the current approach won't work and the agent should try a different plan

  • State changes: A tool detects significant state changes that require the agent to reassess its goals

When caught by the tool loop:

  1. The loop terminates gracefully (no error)

  2. blackboardUpdater is made available for the caller to apply

  3. The caller (typically action executor) can trigger GOAP replanning

Example usage:

@LlmTool(description = "Routes user to appropriate handler")
fun routeUser(message: String): String {
val intent = classifyIntent(message)
throw ReplanRequestedException(
reason = "Classified as $intent request",
blackboardUpdater = { bb -> bb.addObject(intent) }
)
}

Parameters

reason

Human-readable explanation of why replan is needed

blackboardUpdater

Callback to update the blackboard before replanning

Constructors

Link copied to clipboard
constructor(reason: String, blackboardUpdater: BlackboardUpdater = BlackboardUpdater {})

Properties

Link copied to clipboard
Link copied to clipboard
open val cause: Throwable?
Link copied to clipboard
open val message: String?
Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard