turn request_task_implementation return val into a string and add prompt to fix duplicated work.

This commit is contained in:
AI Christianson 2025-02-27 09:06:43 -05:00
parent 8760e6e152
commit d6bcf44700
1 changed files with 38 additions and 3 deletions

View File

@ -237,7 +237,7 @@ def request_research_and_implementation(query: str) -> Dict[str, Any]:
@tool("request_task_implementation")
def request_task_implementation(task_spec: str) -> Dict[str, Any]:
def request_task_implementation(task_spec: str) -> str:
"""Spawn an implementation agent to execute the given task.
Task specs should have the requirements. Generally, the spec will not include any code.
@ -311,7 +311,42 @@ def request_task_implementation(task_spec: str) -> Dict[str, Any]:
}
if work_log is not None:
response_data["work_log"] = work_log
return response_data
# Convert the response data to a markdown string
markdown_parts = []
# Add header and completion message
markdown_parts.append("# Task Implementation")
if response_data.get("completion_message"):
markdown_parts.append(f"\n## Completion Message\n\n{response_data['completion_message']}")
# Add success status
status = "Success" if response_data.get("success", False) else "Failed"
reason_text = f": {response_data.get('reason')}" if response_data.get("reason") else ""
markdown_parts.append(f"\n## Status\n\n**{status}**{reason_text}")
# Add key facts
if response_data.get("key_facts"):
markdown_parts.append(f"\n## Key Facts\n\n{response_data['key_facts']}")
# Add related files
if response_data.get("related_files"):
files_list = "\n".join([f"- {file}" for file in response_data["related_files"]])
markdown_parts.append(f"\n## Related Files\n\n{files_list}")
# Add key snippets
if response_data.get("key_snippets"):
markdown_parts.append(f"\n## Key Snippets\n\n{response_data['key_snippets']}")
# Add work log
if response_data.get("work_log"):
markdown_parts.append(f"\n## Work Log\n\n{response_data['work_log']}")
markdown_parts.append(f"\n\nTHE ABOVE WORK HAS ALREADY BEEN COMPLETED --**DO NOT REQUEST IMPLEMENTATION OF IT AGAIN**")
# Join all parts into a single markdown string
markdown_output = "".join(markdown_parts)
return markdown_output
@tool("request_implementation")
@ -406,7 +441,7 @@ def request_implementation(task_spec: str) -> str:
# Add work log
if response_data.get("work_log"):
markdown_parts.append(f"\n## Work Log\n\n{response_data['work_log']}")
markdown_parts.append(f"\n\nTHE ABOVE WORK HAS ALREADY BEEN COMPLETED --**DO NOT DO THIS WORK AGAIN**")
markdown_parts.append(f"\n\nTHE ABOVE WORK HAS ALREADY BEEN COMPLETED --**DO NOT REQUEST IMPLEMENTATION OF IT AGAIN**")
# Join all parts into a single markdown string
markdown_output = "".join(markdown_parts)