Files
OpenHands/openhands/runtime/plugins/agent_skills
Boxuan Li 75d5591816 file_ops: Use tmp file for original linting (#3681)
Fix a potential issue that might lead to file corruption when edit linting is enabled

#3124 introduces a feature for editing: running linter twice before and after the change and only extract new errors introduced by the agent. This has some potential issues and I am working on #3649 to address them, but I feel like I am not gonna finish it in the next few days, and that PR has become harder and harder to review, thus this PR, which only focuses on a small improvement.

So what's the issue? When we run linters on the original file before our edits, we need to copy the original file and use a temporary file to lint, because linting may have side-effect (e.g. modifying the file in-place). I used the word "may" because:

Flake8 has no side-effect, so not a problem as of now.
We don't enforce this or document this "no side-effect" as a requirement for linter implementation, so side-effect is allowed.
Regardless, the "after-edit-linting" uses the same approach: backup the file before linting to avoid data corruption. We should keep our "before-edit-linting" consistent.

Why no new unittest that reproduces the issue? Well, as I have mentioned earlier, flake8 has no side-effect, so technically it's not a bug but a flaw. Therefore, there's no way to write a test that reproduces the issue.
2024-09-01 23:36:57 -07:00
..

OpenHands Skill Sets

This folder implements a skill/tool set agentskills for OpenHands.

It is intended to be used by the agent inside sandbox. The skill set will be exposed as a pip package that can be installed as a plugin inside the sandbox.

The skill set can contain a bunch of wrapped tools for agent (many examples here), for example:

  • Audio/Video to text (these are a temporary solution, and we should switch to multimodal models when they are sufficiently cheap
  • PDF to text
  • etc.

Inclusion Criteria

We are walking a fine line here. We DON't want to wrap every possible python packages and re-teach agent their usage (e.g., LLM already knows pandas pretty well, so we don't really need create a skill that reads csv - it can just use pandas).

We ONLY want to add a new skill, when:

  • Such skill is not easily achievable for LLM to write code directly (e.g., edit code and replace certain line)
  • It involves calling an external model (e.g., you need to call a speech to text model, editor model for speculative editing)

Intended functionality

  • Tool/skill usage (through IPythonRunAction)
# In[1]
from agentskills import open_file, edit_file
open_file("/workspace/a.txt")
# Out[1]
[SWE-agent open output]

# In[2]
edit_file(
    "/workspace/a.txt",
    start=1, end=3,
    content=(
        ("REPLACE TEXT")
))
# Out[1]
[SWE-agent edit output]
  • Tool/skill retrieval (through IPythonRunAction)
# In[1]
from agentskills import help_me

help_me("I want to solve a task that involves reading a bunch of PDFs and reason about them")

# Out[1]
"Here are the top skills that may be helpful to you:
- `pdf_to_text`: [documentation about the tools]
...
"