picoflow.io

Lesson 10: AddressStep → EndStep


Address Capture with Server Validation

Prompt focuses the model on one tool:

defineTool(): [{
  name: 'address',
  description: 'Capture address of user',
  schema: z.object({ address: z.string() }),
}];
getTool(): ['address', 'end_chat'];

Handler enforces validation in code:

protected async address(tool: ToolCall): Promise<ToolResponseType> {
  const response = ValidateAddress(tool.args?.address);
  if (!response) {
    return { step: AddressStep, tool: 'Invalid address' };
  }
  this.saveState({ address: response });
  return { step: EndStep, prompt: DemoPrompt.AbruptEnd, state: { fromAddress: 5 } };
}
  • Regex + state list guard against malformed inputs.
  • Retry-in-place if invalid; otherwise transition to EndStep.

EndStep Exit

Multiple steps can call EndStep directly or via callStepTool. It centralizes farewell messaging and marks the session complete.


Flow Recap (actual transition path)

WeatherStep → FooLogicStep → GooLogicStep → FavoritesStep → NameStep → DOBStep → AddressStep → EndStep

From here you can optionally branch into the concurrent PresidentStep mini-flow (next lesson).