Skip to content

Conversation

Saedbhati
Copy link
Collaborator

@Saedbhati Saedbhati commented Sep 10, 2025

Description

Describe your changes in detail (optional if the linked issue already contains a detailed description of the changes).
fixes #2464

Doesn't work on windows and need python3.12

Checklist

Go over all the following points, and put an x in all the boxes that apply.

  • I have read the CONTRIBUTION guide (required)
  • I have linked this PR to an issue using the Development section on the right sidebar or by adding Fixes #issue-number in the PR description (required)
  • I have checked if any dependencies need to be added or updated in pyproject.toml and uv lock
  • I have updated the tests accordingly (required for a bug fix or a new feature)
  • I have updated the documentation if needed:
  • I have added examples if this is a new feature

If you are unsure about any of these, don't hesitate to ask. We are here to help!

Copy link
Contributor

coderabbitai bot commented Sep 10, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch enhance-terminal-bench

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Saedbhati Saedbhati changed the base branch from terminal-bench to master September 10, 2025 07:34
@Saedbhati Saedbhati changed the title Enhance terminal bench feat: terminal bench Sep 10, 2025
@hesamsheikh
Copy link
Collaborator

What is this PR about? what issue does it solve?

@Saedbhati
Copy link
Collaborator Author

@hesamsheikh sorry i forget to mention issue, this pr solve #2464

Copy link
Collaborator

@waleedalzarooni waleedalzarooni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @Saedbhati !

A very comprehensive integration, only included a couple of minor comments to help improve slightly.

if os.path.exists(
f"{self.logging_dir}/{container_name}_run{run_id:02d}"
):
run_id += 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this may cause race conditions when multiple processes are running, perhaps consider switching to timestamp based ID's or some atomic directory equivalent!

"""
pb = self._previous_buffer.strip()
if pb in current_buffer:
idx = current_buffer.index(pb)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that there may be some indices overlap here. The method is using an index from a previous buffer as if it's an index in the current buffer. The pb.rfind("\n") can potentially return a position within the previous buffer string, but then this position is used to slice the current buffer

Example:
Previous: "hello\nworld" ← idx=5 points to \n here
Current: "hello\nworld\nnew" ← but we use idx=5 here
Result: "world\nnew" ← wrong! includes "world"
Should be: "new" ← correct! just the new part

Comment on lines 21 to 34
if TYPE_CHECKING:
from terminal_bench.agents.agent_name import ( # type: ignore[import-untyped]
AgentName,
)
from terminal_bench.agents.base_agent import ( # type: ignore[import-untyped]
AgentResult,
BaseAgent,
)
from terminal_bench.handlers.trial_handler import ( # type: ignore[import-untyped]
TrialHandler,
)
from terminal_bench.harness import Harness # type: ignore[import-untyped]
from terminal_bench.terminal.tmux_session import ( # type: ignore[import-untyped]
TmuxSession,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add terminal_bench to pyproject.toml

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@hesamsheikh
Copy link
Collaborator

Thanks for the PR @Saedbhati !
I left a few comments above.

Also, have you been able to example? I got the error

NameError: name 'Harness' is not defined

it's probably that Harness is imported inside a TYPE_CHECKING block, which means it's only available during static type checking, not at runtime. But the TerminalBench class tries to inherit from Harness at runtime, hence the NameError.

Copy link
Collaborator

@waleedalzarooni waleedalzarooni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No major changes so happy with version after comments are carried out

@Saedbhati
Copy link
Collaborator Author

Saedbhati commented Sep 16, 2025

@hesamsheikh I have fix the example, you can give it try.

Copy link
Collaborator

@hesamsheikh hesamsheikh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @Saedbhati
I can run the example. Here are some tiny fixes required.

self,
output_path: Path,
run_id: str,
ChatAgent: ChatAgent,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any specific reason this is not snake_case?

save_to="tbench_results",
processes=1,
)
print(TBench_instance.run(camel_agent=camel_agent, subset=2))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must be

print(TBench_instance.run(agent=camel_agent, subset=2))

Args:
agent: The ChatAgent to use for the benchmark.
on: The data split to run the benchmark on.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must be removed

TerminalToolkit(**terminal_toolkit_kwargs).get_tools() # type: ignore[arg-type]
)

usr_msg = f"{instruction}\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused variable

Copy link
Collaborator

@zjrwtx zjrwtx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @Saedbhati , the advice from @hesamsheikh is nice,and should we update the pyproject.toml? Directory ID generation in a multi-process environment may conflict

total_output_tokens = response.info['usage']['completion_tokens']

memory_list = (
camel_agent._memory._chat_history_block.storage.memory_list # type: ignore[attr-defined]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directly accessing multi-layer private attributes violates the encapsulation principle and is prone to errors when implementing changes internally.

Copy link
Collaborator

@zjrwtx zjrwtx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add more docstring below different core clasee and function

camel_agent: "ChatAgent",
logging_dir: Path | None = None,
) -> "AgentResult":
"""Execute a task using the Terminal Bench harness.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r""""""

def create_timestamped_marker_from_memory(
records: List[dict],
) -> List[Tuple[float, str]]:
"""Create a timestamped marker from memory records."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r""""""

@Saedbhati
Copy link
Collaborator Author

@zjrwbx Thanks a lot for the review. Great to see you back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Review Required PR need to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Integrate terminal bench into benchmarks
5 participants