Skip to content

Commit

Permalink
Fix rethink bug in plan+code due to pre-expanded files
Browse files Browse the repository at this point in the history
  • Loading branch information
roaga committed Nov 2, 2024
1 parent 7c01365 commit 60b9b91
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/seer/automation/autofix/components/coding/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ def invoke(self, request: CodingRequest) -> CodingOutput | None:
)

has_tools = True
if isinstance(request.root_cause_and_fix, RootCauseAnalysisItem):

if (
isinstance(request.root_cause_and_fix, RootCauseAnalysisItem)
and not request.initial_memory
):
expanded_files_messages = []
relevant_files = [
{"file_path": context.snippet.file_path, "repo_name": context.snippet.repo_name}
Expand Down Expand Up @@ -144,6 +148,9 @@ def invoke(self, request: CodingRequest) -> CodingOutput | None:
expanded_files_messages.append(agent_message)
expanded_files_messages.append(user_message)

with self.context.state.update() as cur:
cur.steps[-1].initial_memory_length = len(expanded_files_messages) + 1

if expanded_files_messages and not request.initial_memory:
is_obvious = IsFixObviousComponent(self.context).invoke(
IsFixObviousRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def format_step_one(
Write the next under-20-word conclusion in the chain of thought based on the notes below, or if there is no good conclusion to add, return <NO_INSIGHT/>. The criteria for a good conclusion are that it should be a large, novel jump in insights, not similar to any item in the existing chain of thought, it should be a complete conclusion after some meaty analysis, not a plan of what to analyze next, and it should be valuable for {task_description}. It should also be very concrete, to-the-point, and specific. Every item in the chain of thought should read like a chain that clearly builds off of the previous step. If you can't find a conclusion that meets ALL of these criteria, return <NO_INSIGHT/>.
NOTES TO ANALYZE:
{latest_thought}"""
).format(
task_description=task_description,
Expand Down
1 change: 1 addition & 0 deletions src/seer/automation/autofix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def is_valid_uuid(uuid_string: str) -> bool:
class DefaultStep(BaseStep):
type: Literal[StepType.DEFAULT] = StepType.DEFAULT
insights: list[InsightSharingOutput] = []
initial_memory_length: int = 1


class RootCauseStep(BaseStep):
Expand Down
2 changes: 1 addition & 1 deletion src/seer/automation/autofix/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def truncate_memory_to_match_insights(memory: list[Message], step: DefaultStep):
truncated_memory = new_memory
break
if not step.insights:
truncated_memory = memory[:1]
truncated_memory = memory[: step.initial_memory_length]
return truncated_memory if truncated_memory else memory


Expand Down
2 changes: 2 additions & 0 deletions tests/automation/autofix/test_autofix_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ def test_restart_from_point_with_feedback_root_cause_step(
mock_step = MagicMock(spec=DefaultStep)
mock_step.key = "root_cause_analysis_processing"
mock_step.insights = []
mock_step.initial_memory_length = 1
mock_state.get.return_value.steps = [mock_step]
mock_state.get.return_value.run_id = 123
mock_state.update.return_value.__enter__.return_value.steps = [mock_step]
Expand Down Expand Up @@ -437,6 +438,7 @@ def test_truncate_memory_to_match_insights(self):
MagicMock(spec=InsightSharingOutput, generated_at_memory_index=4),
MagicMock(spec=InsightSharingOutput, generated_at_memory_index=-1),
]
mock_step.initial_memory_length = 1

# Create a mock memory list
memory = [
Expand Down

0 comments on commit 60b9b91

Please sign in to comment.