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

@@ -821,6 +821,12 @@ func (a *Agent) thinkAndAct(ctx context.Context, storeUserID string, userID int6
lock := a.flowLock(userID)
lock.Lock()
defer lock.Unlock()
if a.shouldUseAgenticTurn(userID) {
if answer, ok, err := a.runAgenticTurn(ctx, storeUserID, userID, lang, text, nil); ok || err != nil {
return a.maybeAppendResumePrompt(userID, lang, text, answer), err
}
// Not handled — fall through to the legacy routing stack.
}
if a.aiClient != nil {
if answer, ok, err := a.tryLLMIntentRoute(ctx, storeUserID, userID, lang, text, nil); ok || err != nil {
return a.maybeAppendResumePrompt(userID, lang, text, answer), err
@@ -852,6 +858,12 @@ func (a *Agent) thinkAndActStream(ctx context.Context, storeUserID string, userI
lock := a.flowLock(userID)
lock.Lock()
defer lock.Unlock()
if a.shouldUseAgenticTurn(userID) {
if answer, ok, err := a.runAgenticTurn(ctx, storeUserID, userID, lang, text, onEvent); ok || err != nil {
return a.maybeAppendResumePrompt(userID, lang, text, answer), err
}
// Not handled — fall through to the legacy routing stack.
}
if a.aiClient != nil {
if answer, ok, err := a.tryLLMIntentRoute(ctx, storeUserID, userID, lang, text, onEvent); ok || err != nil {
answer = a.maybeAppendResumePrompt(userID, lang, text, answer)