summaryrefslogtreecommitdiff
path: root/internal/executor
diff options
context:
space:
mode:
Diffstat (limited to 'internal/executor')
-rw-r--r--internal/executor/container.go28
-rw-r--r--internal/executor/container_test.go42
-rw-r--r--internal/executor/helpers.go26
3 files changed, 0 insertions, 96 deletions
diff --git a/internal/executor/container.go b/internal/executor/container.go
index f78715d..3afce70 100644
--- a/internal/executor/container.go
+++ b/internal/executor/container.go
@@ -403,34 +403,6 @@ func (r *ContainerRunner) runContainer(ctx context.Context, t *task.Task, e *sto
return &BlockedError{QuestionJSON: q, SessionID: e.SessionID, SandboxDir: workspace}
}
- // Check whether the agent left a question before exiting (file fallback for
- // in-flight tasks started on the pre-MCP wire).
- questionFile := filepath.Join(logDir, "question.json")
- if data, readErr := os.ReadFile(questionFile); readErr == nil {
- os.Remove(questionFile) // consumed
- questionJSON := strings.TrimSpace(string(data))
- if isCompletionReport(questionJSON) {
- r.Logger.Info("treating question file as completion report", "taskID", e.TaskID)
- _ = ch.ReportSummary(ctx, extractQuestionText(questionJSON))
- } else {
- if e.SessionID == "" {
- r.Logger.Warn("missing session ID; resume will start fresh", "taskID", e.TaskID)
- }
- return &BlockedError{
- QuestionJSON: questionJSON,
- SessionID: e.SessionID,
- SandboxDir: workspace,
- }
- }
- }
-
- // Read agent summary if written.
- summaryFile := filepath.Join(logDir, "summary.txt")
- if summaryData, readErr := os.ReadFile(summaryFile); readErr == nil {
- os.Remove(summaryFile) // consumed
- _ = ch.ReportSummary(ctx, strings.TrimSpace(string(summaryData)))
- }
-
// 5. Post-execution: push changes if successful
if waitErr == nil && streamErr == nil {
// Check if there are any commits to push (HEAD ahead of origin/HEAD).
diff --git a/internal/executor/container_test.go b/internal/executor/container_test.go
index 5c3fd2e..26e67bc 100644
--- a/internal/executor/container_test.go
+++ b/internal/executor/container_test.go
@@ -269,48 +269,6 @@ func TestBlockedError_IncludesSandboxDir(t *testing.T) {
}
}
-func TestIsCompletionReport(t *testing.T) {
- tests := []struct {
- name string
- json string
- expected bool
- }{
- {
- name: "real question with options",
- json: `{"text": "Should I proceed with implementation?", "options": ["Yes", "No"]}`,
- expected: false,
- },
- {
- name: "real question no options",
- json: `{"text": "Which approach do you prefer?"}`,
- expected: false,
- },
- {
- name: "completion report no options no question mark",
- json: `{"text": "All tests pass. Implementation complete. Summary written to CLAUDOMATOR_SUMMARY_FILE."}`,
- expected: true,
- },
- {
- name: "completion report with empty options",
- json: `{"text": "Feature implemented and committed.", "options": []}`,
- expected: true,
- },
- {
- name: "invalid json treated as not a report",
- json: `not json`,
- expected: false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- got := isCompletionReport(tt.json)
- if got != tt.expected {
- t.Errorf("isCompletionReport(%q) = %v, want %v", tt.json, got, tt.expected)
- }
- })
- }
-}
-
func TestTailFile_ReturnsLastNLines(t *testing.T) {
f, err := os.CreateTemp("", "tailfile-*")
if err != nil {
diff --git a/internal/executor/helpers.go b/internal/executor/helpers.go
index 76bf8b1..9517492 100644
--- a/internal/executor/helpers.go
+++ b/internal/executor/helpers.go
@@ -177,29 +177,3 @@ func gitSafe(args ...string) []string {
"-c", "tag.gpgsign=false",
}, args...)
}
-
-// isCompletionReport returns true when a question-file JSON looks like a
-// completion report rather than a real user question. Heuristic: no options
-// (or empty options) and no "?" anywhere in the text.
-func isCompletionReport(questionJSON string) bool {
- var q struct {
- Text string `json:"text"`
- Options []string `json:"options"`
- }
- if err := json.Unmarshal([]byte(questionJSON), &q); err != nil {
- return false
- }
- return len(q.Options) == 0 && !strings.Contains(q.Text, "?")
-}
-
-// extractQuestionText returns the "text" field from a question-file JSON, or
-// the raw string if parsing fails.
-func extractQuestionText(questionJSON string) string {
- var q struct {
- Text string `json:"text"`
- }
- if err := json.Unmarshal([]byte(questionJSON), &q); err != nil {
- return questionJSON
- }
- return strings.TrimSpace(q.Text)
-}