feat: add OpenAI/Anthropic tools support with tool emulation

- Parse tools/tool_choice from OpenAI and Anthropic requests
- Inject tool definitions into system prompt via toolemulation
- Parse action blocks (```json action) from model responses
- Retry logic for forced tool_choice (any/required)
- Return proper tool_calls / tool_use in responses
- Support streaming tools via collect-and-replay pattern
- Add tool history projection (assistant tool_calls + tool results)
- Model ID normalization: use official names (Qwen3.6-Plus, etc.)
- Fix resolveSessionMode to use Fresh mode when tools present
This commit is contained in:
lutc5
2026-04-25 13:37:58 +08:00
parent c49b4b63e7
commit 74bbd8e6d2
13 changed files with 648 additions and 115 deletions

View File

@@ -10,6 +10,7 @@ import (
"os"
"os/signal"
"path/filepath"
"runtime"
"strconv"
"strings"
"syscall"
@@ -88,7 +89,7 @@ func loadConfig() (service.Config, string) {
Transport: lingmaipc.TransportAuto,
Cwd: currentDir(),
Mode: "agent",
ShellType: "powershell",
ShellType: defaultShellType(),
SessionMode: service.SessionModeAuto,
Timeout: 120 * time.Second,
}
@@ -299,3 +300,10 @@ func valueOr(value string, fallback string) string {
}
return fallback
}
func defaultShellType() string {
if runtime.GOOS == "windows" {
return "powershell"
}
return "zsh"
}