SayCanPay: LLM & Heuristic Planning
- SayCanPay is a planning framework that integrates LLM-generated proposals, learned affordance evaluation, and reward estimation to produce grounded, cost-effective plans.
- It decomposes the planning process into three modules—Say (LLM proposal), Can (feasibility check), and Pay (reward estimation)—using a heuristic search strategy.
- Experimental evaluations demonstrate that SayCanPay outperforms baseline methods in planning success and efficiency across diverse tasks like robotics and payment workflows.
SayCanPay is a planning framework that integrates the world knowledge of LLMs with learnable domain knowledge and heuristic search to generate plans that are both feasible (affordance-grounded) and cost-effective in terms of plan length. Developed to address limitations of pure-LLM and classical heuristic planning, SayCanPay combines three complementary modules—Say (LLM plan proposals), Can (learned affordance evaluator), and Pay (learned reward/payoff estimator)—within a heuristic search procedure over action sequences. This architecture generalizes across domains, from language-based embodied tasks to end-to-end agentic payment workflows, and has demonstrated superior planning success, cost-effectiveness, and generalization relative to baseline LLM or heuristic-only methods (Hazra et al., 2023, Chua et al., 27 Feb 2026).
1. Formal Problem Formulation
SayCanPay frames planning as a finite-horizon partially observable Markov decision process (POMDP) defined as , where:
- is the (hidden) state space; a goal set.
- is the initial belief (one-hot at ).
- is the discrete action set; is the observation set, with .
- is a sparse reward (success/failure).
- is the transition kernel.
The planning objective is, given a natural-language goal 0 and initial history 1, to find an action sequence 2 maximizing 3. The value function is factorized as: 4 where 5 is the log-probability of prior actions, 6 is the model likelihood for the next action (“Say”), and 7 is a learned estimate of expected future reward (“Pay”). Specializations correspond to greedy best-first or A*-like strategies, depending on the combination of terms and search procedure (Hazra et al., 2023).
2. Say, Can, and Pay Modules
The SayCanPay framework decomposes heuristic planning into three distinct modules:
- Say module: A pretrained LLM (e.g., Vicuna-13B, Flan-T5-11B) prompts to generate candidate actions at each step. Candidates are selected by beam search or greedy decoding over language outputs, mapped via edit distance to admissible domain actions. The log-likelihood 8 forms the “Say” component.
- Can module: A BERT-based binary classifier 9 trained on expert demonstrations estimates the feasibility of candidate actions, outputting 0, reflecting whether action preconditions are met. Negative samples are drawn by swapping time steps and/or sampling unrelated actions in trajectory space. The loss uses InfoNCE over batch.
- Pay module: A BERT-based regression model 1 estimates the expected, discounted, arc-to-go reward 2 by back-propagating terminal rewards along expert trajectories and discounting by 3. Negative samples (off-expert trajectories) receive zero reward. Mean squared error loss is used for training. Both 4 and 5 share architecture and optimizer: uncased BERT, AdamW (6, weight decay 7, batch=50), trained for 20 epochs (Hazra et al., 2023).
The combined score for an action sequence is given by: 8 i.e., SayCanPay = Say 9 Can 0 Pay.
3. Heuristic Search Framework
SayCanPay uses the output of the Say, Can, and Pay modules in classical heuristic-search algorithms:
- Greedy-Action: At step 1, expand the current state by proposing actions via Say, scoring each with SayCanPay, and selecting the highest-scoring candidate.
- Beam-Action: Maintain 2 beams, expanding each by 3 candidates, scoring each descendant: 4 Prune to the top-5 beams by length-normalized score and continue expansion until termination.
Each beam is a complete sequence of actions to the goal or until maximum allowed length. This results in grounded, reward-oriented plan sequences, outperforming LLM-only or heuristic-only strategies in experimental benchmarks (Hazra et al., 2023).
4. Experimental Evaluation
SayCanPay has been evaluated on multiple domains:
- Ravens tasks: Tower of Hanoi (mean plan length 3.3, 6), Put Blocks in Bowls (6.1, 7).
- BabyAI: Pickup tasks, mean length 6.7.
- VirtualHome: Household activities, length 5.9, 8.
Training data consisted of 9800 expert trajectories per Ravens/VirtualHome task, 0400 for BabyAI; 100 test episodes per split. SayCanPay leverages off-the-shelf LLMs for Say, without LM fine-tuning.
Key results (\textit{beam size k=3, per-task Flan-T5/Vicuna-13B, success rates}):
- Ravens (Hanoi): SayCanPay Beam 70\%/50\% vs. Say 54\%/38\%.
- Ravens (Blocks): 56\%/98\% vs. 52\%/98\%.
- BabyAI: 94\%/36\% vs. 72\%/1\%.
- VirtualHome: 53\%/50\% vs. 48\%/30\%.
- Cost-effectiveness (optimal length plans) highest for SayCanPay, e.g., Ravens (Hanoi): 34\%/26\% vs. 27\%/26\% for Say.
- Generalization to OOD tasks: SayCanPay achieves up to +89\% over greedy.
Planning time per episode (Vicuna-13B): Greedy-Token 9 s, Greedy-Action 17 s, Beam-Action 35 s; Can/Pay add negligible overhead. Say (LM proposal) remains the primary computational bottleneck.
Ablation studies show that increasing beam size monotonically improves plan success and optimality; “Perfect Say” oracle (always proposes the correct action) increases success by 16–84 percentage points, localizing bottlenecks to the action-generation stage. Scalability is favorable since action space size does not increase LLM inference time, as candidates are generated, not enumerated (Hazra et al., 2023).
5. Extension to Agentic Payment Workflows
SayCanPay has been generalized to payment workflows via a hierarchical multi-agent system (HMASP), structured in four levels:
- Level I (CPA): Conversational Payment Agent serves as natural-language entry, intent parsing, routing, and final consolidation.
- Level II (Supervisors): CardsSupervisor and PaymentsSupervisor manage orthogonal state: card onboarding/retrieval and payment initiation/history, respectively.
- Level III (Routing Agents): Specialized for specific sub-tasks (e.g., CardRegistrationRouter, PaymentProcessingRouter), trigger deterministic function modules.
- Level IV (Process Summary Agents): Aggregate results, produce structured summaries, and propagate outputs upstream.
State management combines persisted role-based state (1, 2, 3) with decoupled message buffers 4 per agent. The handoff protocol between agents is governed by a probability model over successors, computed via LLM prompt and softmax. Transition selection is modeled as: 5 with agent transitions choosing the highest-probability next agent or REJECT.
Experimental evaluation on a 1,000-point payment workflow dataset shows mean task success rate 97.7\% (Qwen2.5:32b), handoff F1 99.2\%, and near-parity between Qwen2.5 and GPT-4.1 (Chua et al., 27 Feb 2026).
6. Practical Considerations and Limitations
- Deterministic vs. LLM boundaries: All sensitive data handling, validation (Luhn, CVV, expiry), cryptographic operations, and API gateway invocations are fully deterministic. LLMs serve exclusively for natural language intent, agent handoffs, and summary/error generation; no raw PAN or CVV flows through prompts.
- Risk and compliance: Anti-fraud checks (velocity, geo-velocity, device, etc.) are performed by deterministic modules, with an LLM-augmented agent for interpretability and escalation. PCI DSS constraints are adhered to via strict data isolation.
- Robustness: Faults or timeouts in Routing agents result in structured error propagation to Summary agents for graceful failure communication.
Failure modes are primarily attributed to the Say step (LM generation failures/omissions), and to Can/Pay models failing to extrapolate beyond trained domains. A plausible implication is that online adaptation or symbolic heuristics could further enhance OOD robustness (Hazra et al., 2023).
7. Impact, Generalization, and Future Directions
SayCanPay demonstrates that the fusion of LLM world knowledge, learned feasibility, and long-horizon reward modeling under classical heuristic search yields grounded, cost-efficient plans and workflows, bridging gaps between data-driven and symbolic planning methods. Its architecture has enabled the first end-to-end multi-agent conversational payment system capable of operating across hierarchical functional boundaries, modularizing state, and maintaining agentic explainability (Chua et al., 27 Feb 2026).
Potential future research directions include adaptive domain model learning, symbolic-LLM hybrid heuristics, and extension to broader real-world transactional domains, with particular attention to safety, compliance, and further reducing reliance on LLM action proposal bottlenecks.
References
- SayCanPay: Heuristic Planning with LLMs using Learnable Domain Knowledge (Hazra et al., 2023)
- A Novel Hierarchical Multi-Agent System for Payments Using LLMs (Chua et al., 27 Feb 2026)