Federico Mariani created CAMEL-27251:
----------------------------------------

             Summary: camel-ai - ask a person to confirm a tool call before it 
runs, with the same behaviour in spring-ai-chat, openai and langchain4j-agent
                 Key: CAMEL-27251
                 URL: https://issues.apache.org/jira/browse/CAMEL-27251
             Project: Camel
          Issue Type: New Feature
          Components: camel-spring-ai, camel-langchain4j-agent, camel-ai, 
camel-openai
            Reporter: Federico Mariani


Some tools change things that a person should approve first, such as cancelling 
an order, refunding a payment or deleting data. A human-in-the-loop step for 
them: the model asks for the tool, the call does not run, and the exchange ends 
with the pending calls. A later request with the decisions (allow, or deny with 
a message) runs the allowed calls and continues the conversation. Nothing waits 
in Camel while the decision is pending, so it can come much later, from another 
route or instance: a mail, a chat message, a REST call, a task list.

Spring AI 2.1.0 supports this in its tool loop ("tool call confirmation": 
{{ToolMetadata.requiresConfirmation}}, {{ToolCallConfirmationPolicy}}, 
{{ToolCallDecision}}, {{ToolCallingManager.executeToolCalls(prompt, reply, 
decisions)}}). camel-openai runs its own tool loop and camel-langchain4j-agent 
runs it through LangChain4j, so each needs its own pause and resume.

It would be nice to have an aligned behaviour in the AI components that run 
ai-tool routes (spring-ai-chat, openai, langchain4j-agent), rather than a 
feature of one of them:

* One way to mark a tool: an ai-tool route option such as 
{{requiresConfirmation}}, and maybe an endpoint option naming tools, for MCP 
tools and tools that are not routes.
* The same pause headers in every component (a waiting flag, and the pending 
calls with id, name and arguments) and the same resume headers (the decisions, 
the deny message).
* The paused reply is kept by the conversation memory of the component and read 
back on resume, never taken from the request. A new message instead of a 
decision closes the pause, and its calls do not run.
* A component that cannot pause never runs a marked tool: it leaves the tool 
out of what it offers to the model. camel-mcp-server does not publish it, or 
later supports it with MCP elicitation.

h3. Notes from a first spike on spring-ai-chat (CAMEL-27244, not merged)

* Spring AI's default tool calling manager already pauses on a callback whose 
metadata says {{requiresConfirmation}}, also in a {{ChatClient}} built by the 
user, so spring-ai-chat mostly has to mark the callbacks and resume.
* Spring AI's {{JdbcChatMemoryRepository}} does not store assistant messages 
with tool calls, nor tool responses. Resume then needs session memory 
(CAMEL-27243) or another store that keeps them.
* A wrapper on the marked callbacks that refuses to run them outside a resume 
protects against a tool calling manager that ignores the flag.
* Left out of the spike: resume when the caller keeps the conversation 
({{CHAT_MULTIPLE_MESSAGES}}), a configurable confirmation policy, two 
concurrent resumes of one conversation, and who is allowed to decide.

_Claude Code on behalf of Croway_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to