feat(agent): make the agentic loop the primary brain path

thinkAndAct/thinkAndActStream now try the native function-calling loop
first for fresh conversations; in-flight legacy flows (skill sessions,
workflows, execution states, pending proposals) stay on the legacy stack
until they finish. NOFX_AGENT_V2=off restores the old routing entirely.
This commit is contained in:
tinkle-community
2026-06-11 01:03:08 +08:00
parent 785922697b
commit f3c33b55d7
3 changed files with 70 additions and 0 deletions

View File

@@ -32,6 +32,23 @@ func agentV2Enabled() bool {
return true
}
// shouldUseAgenticTurn reports whether this turn should go through the native
// function-calling loop. In-flight legacy flows (skill sessions, workflows,
// execution states, pending proposals) stay on the legacy stack so they finish
// with the state machine that started them.
func (a *Agent) shouldUseAgenticTurn(userID int64) bool {
if a.aiClient == nil || !agentV2Enabled() {
return false
}
if a.hasAnyActiveContext(userID) {
return false
}
if _, ok := a.getPendingProposalSession(userID); ok {
return false
}
return true
}
// runAgenticTurn drives one user turn through a native function-calling loop:
// the LLM sees the full toolset plus recent conversation, decides which tools
// to call, receives every tool result (including errors) as observations, and