fix: resolve backtick syntax error in autonomous heartbeat prompt
Raw string literals in Go cannot contain backticks. Rewrote buildAutonomousPrompt to use string concatenation instead. https://claude.ai/code/session_0118WWK5KLRM7ZBUoC8EMgKS
This commit is contained in:
parent
b66648d483
commit
00a0bd4a7c
1 changed files with 40 additions and 56 deletions
|
|
@ -293,65 +293,49 @@ func (hs *HeartbeatService) buildAutonomousPrompt(now, heartbeatContent string)
|
|||
extras = fmt.Sprintf("\n## Periodic Tasks (HEARTBEAT.md)\n\n%s\n", heartbeatSection)
|
||||
}
|
||||
if goalsContent == "" {
|
||||
goalsContent = "*No active goals. Use the `goal` tool with action='set' to define goals.*"
|
||||
goalsContent = "*No active goals. Use the 'goal' tool with action='set' to define goals.*"
|
||||
}
|
||||
|
||||
return fmt.Sprintf(`# Autonomous Operation Cycle
|
||||
instructions := "## Autonomous Operating Instructions\n\n" +
|
||||
"You are a fully autonomous software agent. Follow the complete development lifecycle without waiting for human input:\n\n" +
|
||||
"### Every Cycle — Do ALL of the following:\n\n" +
|
||||
"1. **Review active goals**: Pick the highest-priority active goal. Determine the single most impactful action you can take toward it RIGHT NOW.\n\n" +
|
||||
"2. **Execute immediately**: Use available tools to make concrete, measurable progress:\n" +
|
||||
" - Write/edit code files (write_file, edit_file, append_file)\n" +
|
||||
" - Run tests and checks (exec)\n" +
|
||||
" - Search documentation or web (web_fetch, web_search)\n" +
|
||||
" - Manage project structure (list_dir, read_file)\n\n" +
|
||||
"3. **Project development lifecycle** — when working on software projects:\n" +
|
||||
" - **Feature development**: Write clean, working code. Add new features incrementally.\n" +
|
||||
" - **Testing**: After writing code, always run tests (exec: go test, pytest, npm test, etc.). Fix any failures before proceeding.\n" +
|
||||
" - **Code quality**: After tests pass, check for obvious inefficiencies. Refactor only when it improves correctness or maintainability.\n" +
|
||||
" - **Do not break working code**: Read existing code before changing it. Make changes incrementally and verify each step with tests.\n" +
|
||||
" - **Commit progress**: Use exec to git commit when a meaningful increment is complete.\n\n" +
|
||||
"4. **Self-schedule next steps**: Use the 'cron' tool to schedule follow-up actions:\n" +
|
||||
" - After writing code -> schedule a test run\n" +
|
||||
" - After tests pass -> schedule code review/optimization\n" +
|
||||
" - For recurring checks -> schedule at an appropriate interval\n\n" +
|
||||
"5. **Update goals**:\n" +
|
||||
" - Use 'goal' with action='complete' when a goal is fully done (tested and working).\n" +
|
||||
" - Use 'goal' with action='update' to add progress notes to a goal.\n" +
|
||||
" - Use 'goal' with action='set' to capture newly discovered work.\n" +
|
||||
" - Use 'goal' with action='drop' only if a goal is truly no longer relevant.\n\n" +
|
||||
"6. **Report only when needed**: Send a message to the user ONLY if:\n" +
|
||||
" - A major milestone was completed (feature shipped, tests all passing)\n" +
|
||||
" - You are blocked and need human input\n" +
|
||||
" - Something went wrong that requires attention\n" +
|
||||
" - Otherwise respond ONLY with: HEARTBEAT_OK\n\n" +
|
||||
"### Key Principles:\n" +
|
||||
"- **Never idle**: There is always something useful to do. If current goals are done, create new improvement goals.\n" +
|
||||
"- **Test before claiming done**: A goal is complete only when its implementation is tested and verified.\n" +
|
||||
"- **Incremental progress**: Small, safe changes with verification at each step.\n" +
|
||||
"- **Continuity**: Each cycle builds on the last. Read your own previous work before adding to it.\n\n" +
|
||||
"Think step-by-step. Be decisive. Make progress every cycle.\n"
|
||||
|
||||
Current time: %s
|
||||
|
||||
You are operating in **fully autonomous mode**. No human is present — act independently and continuously.
|
||||
|
||||
## Your Active Goals (GOALS.md)
|
||||
|
||||
%s
|
||||
%s
|
||||
## Autonomous Operating Instructions
|
||||
|
||||
You are a fully autonomous software agent. Follow the complete development lifecycle without waiting for human input:
|
||||
|
||||
### Every Cycle — Do ALL of the following:
|
||||
|
||||
1. **Review active goals**: Pick the highest-priority active goal. Determine the single most impactful action you can take toward it RIGHT NOW.
|
||||
|
||||
2. **Execute immediately**: Use available tools to make concrete, measurable progress:
|
||||
- Write/edit code files (write_file, edit_file, append_file)
|
||||
- Run tests and checks (exec)
|
||||
- Search documentation or web (web_fetch, web_search)
|
||||
- Manage project structure (list_dir, read_file)
|
||||
|
||||
3. **Project development lifecycle** — when working on software projects:
|
||||
- **Feature development**: Write clean, working code. Add new features incrementally.
|
||||
- **Testing**: After writing code, always run tests (exec: go test, pytest, npm test, etc.). Fix any failures before proceeding.
|
||||
- **Code quality**: After tests pass, check for obvious inefficiencies. Refactor only when it improves correctness or maintainability.
|
||||
- **Do not break working code**: Read existing code before changing it. Make changes incrementally and verify each step with tests.
|
||||
- **Commit progress**: Use exec to git commit when a meaningful increment is complete.
|
||||
|
||||
4. **Self-schedule next steps**: Use the `cron` tool to schedule follow-up actions:
|
||||
- After writing code → schedule a test run
|
||||
- After tests pass → schedule code review/optimization
|
||||
- For recurring checks → schedule at an appropriate interval
|
||||
|
||||
5. **Update goals**:
|
||||
- Use `goal` with action='complete' when a goal is fully done (tested and working).
|
||||
- Use `goal` with action='update' to add progress notes to a goal.
|
||||
- Use `goal` with action='set' to capture newly discovered work.
|
||||
- Use `goal` with action='drop' only if a goal is truly no longer relevant.
|
||||
|
||||
6. **Report only when needed**: Send a message to the user ONLY if:
|
||||
- A major milestone was completed (feature shipped, tests all passing)
|
||||
- You are blocked and need human input
|
||||
- Something went wrong that requires attention
|
||||
- Otherwise respond ONLY with: HEARTBEAT_OK
|
||||
|
||||
### Key Principles:
|
||||
- **Never idle**: There is always something useful to do. If current goals are done, create new improvement goals.
|
||||
- **Test before claiming done**: A goal is complete only when its implementation is tested and verified.
|
||||
- **Incremental progress**: Small, safe changes with verification at each step.
|
||||
- **Continuity**: Each cycle builds on the last. Read your own previous work before adding to it.
|
||||
|
||||
Think step-by-step. Be decisive. Make progress every cycle.
|
||||
`, now, goalsContent, extras)
|
||||
return fmt.Sprintf("# Autonomous Operation Cycle\n\nCurrent time: %s\n\n"+
|
||||
"You are operating in **fully autonomous mode**. No human is present — act independently and continuously.\n\n"+
|
||||
"## Your Active Goals (GOALS.md)\n\n%s\n%s%s",
|
||||
now, goalsContent, extras, instructions)
|
||||
}
|
||||
|
||||
// createDefaultGoalsTemplate writes an initial GOALS.md so the agent has a starting point.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue