remove wrapper methods
Signed-off-by: Kai Xia <kaix+github@fastmail.com>
This commit is contained in:
parent
35753c20ca
commit
7d409f3373
3 changed files with 5 additions and 18 deletions
|
|
@ -100,17 +100,12 @@ func (p *ClaudeCliProvider) buildSystemPrompt(messages []Message, tools []ToolDe
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(tools) > 0 {
|
if len(tools) > 0 {
|
||||||
parts = append(parts, p.buildToolsPrompt(tools))
|
parts = append(parts, buildCLIToolsPrompt(tools))
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(parts, "\n\n")
|
return strings.Join(parts, "\n\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildToolsPrompt creates the tool definitions section for the system prompt.
|
|
||||||
func (p *ClaudeCliProvider) buildToolsPrompt(tools []ToolDefinition) string {
|
|
||||||
return buildCLIToolsPrompt(tools)
|
|
||||||
}
|
|
||||||
|
|
||||||
// parseClaudeCliResponse parses the JSON output from the claude CLI.
|
// parseClaudeCliResponse parses the JSON output from the claude CLI.
|
||||||
func (p *ClaudeCliProvider) parseClaudeCliResponse(output string) (*LLMResponse, error) {
|
func (p *ClaudeCliProvider) parseClaudeCliResponse(output string) (*LLMResponse, error) {
|
||||||
var resp claudeCliJSONResponse
|
var resp claudeCliJSONResponse
|
||||||
|
|
|
||||||
|
|
@ -660,12 +660,11 @@ func TestBuildSystemPrompt_ToolsOnlyNoSystem(t *testing.T) {
|
||||||
// --- buildToolsPrompt tests ---
|
// --- buildToolsPrompt tests ---
|
||||||
|
|
||||||
func TestBuildToolsPrompt_SkipsNonFunction(t *testing.T) {
|
func TestBuildToolsPrompt_SkipsNonFunction(t *testing.T) {
|
||||||
p := NewClaudeCliProvider("/workspace")
|
|
||||||
tools := []ToolDefinition{
|
tools := []ToolDefinition{
|
||||||
{Type: "other", Function: ToolFunctionDefinition{Name: "skip_me"}},
|
{Type: "other", Function: ToolFunctionDefinition{Name: "skip_me"}},
|
||||||
{Type: "function", Function: ToolFunctionDefinition{Name: "include_me", Description: "Included"}},
|
{Type: "function", Function: ToolFunctionDefinition{Name: "include_me", Description: "Included"}},
|
||||||
}
|
}
|
||||||
got := p.buildToolsPrompt(tools)
|
got := buildCLIToolsPrompt(tools)
|
||||||
if strings.Contains(got, "skip_me") {
|
if strings.Contains(got, "skip_me") {
|
||||||
t.Error("buildToolsPrompt() should skip non-function tools")
|
t.Error("buildToolsPrompt() should skip non-function tools")
|
||||||
}
|
}
|
||||||
|
|
@ -675,11 +674,10 @@ func TestBuildToolsPrompt_SkipsNonFunction(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildToolsPrompt_NoDescription(t *testing.T) {
|
func TestBuildToolsPrompt_NoDescription(t *testing.T) {
|
||||||
p := NewClaudeCliProvider("/workspace")
|
|
||||||
tools := []ToolDefinition{
|
tools := []ToolDefinition{
|
||||||
{Type: "function", Function: ToolFunctionDefinition{Name: "bare_tool"}},
|
{Type: "function", Function: ToolFunctionDefinition{Name: "bare_tool"}},
|
||||||
}
|
}
|
||||||
got := p.buildToolsPrompt(tools)
|
got := buildCLIToolsPrompt(tools)
|
||||||
if !strings.Contains(got, "bare_tool") {
|
if !strings.Contains(got, "bare_tool") {
|
||||||
t.Error("should include tool name")
|
t.Error("should include tool name")
|
||||||
}
|
}
|
||||||
|
|
@ -689,14 +687,13 @@ func TestBuildToolsPrompt_NoDescription(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildToolsPrompt_NoParameters(t *testing.T) {
|
func TestBuildToolsPrompt_NoParameters(t *testing.T) {
|
||||||
p := NewClaudeCliProvider("/workspace")
|
|
||||||
tools := []ToolDefinition{
|
tools := []ToolDefinition{
|
||||||
{Type: "function", Function: ToolFunctionDefinition{
|
{Type: "function", Function: ToolFunctionDefinition{
|
||||||
Name: "no_params_tool",
|
Name: "no_params_tool",
|
||||||
Description: "A tool with no parameters",
|
Description: "A tool with no parameters",
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
got := p.buildToolsPrompt(tools)
|
got := buildCLIToolsPrompt(tools)
|
||||||
if strings.Contains(got, "Parameters:") {
|
if strings.Contains(got, "Parameters:") {
|
||||||
t.Error("should not include Parameters: section when nil")
|
t.Error("should not include Parameters: section when nil")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ func (p *CodexCliProvider) buildPrompt(messages []Message, tools []ToolDefinitio
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(tools) > 0 {
|
if len(tools) > 0 {
|
||||||
sb.WriteString(p.buildToolsPrompt(tools))
|
sb.WriteString(buildCLIToolsPrompt(tools))
|
||||||
sb.WriteString("\n\n")
|
sb.WriteString("\n\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,11 +128,6 @@ func (p *CodexCliProvider) buildPrompt(messages []Message, tools []ToolDefinitio
|
||||||
return sb.String()
|
return sb.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildToolsPrompt creates a tool definitions section for the prompt.
|
|
||||||
func (p *CodexCliProvider) buildToolsPrompt(tools []ToolDefinition) string {
|
|
||||||
return buildCLIToolsPrompt(tools)
|
|
||||||
}
|
|
||||||
|
|
||||||
// codexEvent represents a single JSONL event from `codex exec --json`.
|
// codexEvent represents a single JSONL event from `codex exec --json`.
|
||||||
type codexEvent struct {
|
type codexEvent struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue