From 7ae4c61af651cac561c380e00a5c0e202284438c Mon Sep 17 00:00:00 2001 From: AI Christianson Date: Tue, 25 Feb 2025 14:59:13 -0500 Subject: [PATCH] fix interactive capture; fix prompts --- ra_aid/proc/interactive.py | 20 ++++++++++++++++---- ra_aid/tools/expert.py | 4 ++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ra_aid/proc/interactive.py b/ra_aid/proc/interactive.py index 1428e67..8a57202 100644 --- a/ra_aid/proc/interactive.py +++ b/ra_aid/proc/interactive.py @@ -399,12 +399,25 @@ def run_interactive_command( decoded = raw_output.decode("utf-8", errors="ignore") stream.feed(decoded) - # Get only the current display (final screen state), not the entire history - display_lines = [render_line(line, cols) for line in screen.display] + # Get all history lines (top and bottom) and current display + all_lines = [] + + # Add history.top lines (older history) + for line_num in sorted(screen.history.top): + line = screen.history.top[line_num] + all_lines.append(render_line(line, cols)) + + # Add current display lines + all_lines.extend([render_line(line, cols) for line in screen.display]) + + # Add history.bottom lines (newer history) + for line_num in sorted(screen.history.bottom): + line = screen.history.bottom[line_num] + all_lines.append(render_line(line, cols)) # Trim out empty lines to get only meaningful lines # Also strip trailing whitespace from each line - trimmed_lines = [line.rstrip() for line in display_lines if line and line.strip()] + trimmed_lines = [line.rstrip() for line in all_lines if line and line.strip()] final_output = "\n".join(trimmed_lines) except Exception as e: @@ -434,7 +447,6 @@ def run_interactive_command( # Handle any unexpected type final_output = str(final_output)[-8000:].encode("utf-8") - print("HERE", final_output) return final_output, proc.returncode diff --git a/ra_aid/tools/expert.py b/ra_aid/tools/expert.py index 6bb1a69..cd8183e 100644 --- a/ra_aid/tools/expert.py +++ b/ra_aid/tools/expert.py @@ -49,7 +49,7 @@ def emit_expert_context(context: str) -> str: Do not include your question in the additional context. - Err on the side of adding more context rather than less. + Err on the side of adding more context rather than less, but keep it information dense and under 500 words total. You must give the complete contents. @@ -135,7 +135,7 @@ def ask_expert(question: str) -> str: The expert can be extremely useful at logic questions, debugging, and reviewing complex source code, but you must provide all context including source manually. - The can see any key facts and code snippets previously noted, along with any additional context you've provided. + The expert can see any key facts and code snippets previously noted, along with any additional context you've provided. But the expert cannot see or reason about anything you have not explicitly provided in this way. Try to phrase your question in a way that it does not expand the scope of our top-level task.