Skip to content

get_dependency agent tool #7

@mcelrath

Description

@mcelrath

Create an agent tool like get_dependency that will get the full source code for an actual dependency in a project. For instance consider a Rust project and running cargo build -v -- it tells you the relevant file:

error[E0599]: no function or associated item named `xx` found for struct `libp2p::libp2p_noise::Config` in the current scope
   --> relay_test_client_destination/src/main.rs:40:37
    |
40  |     let noise_config = NoiseConfig::xx(identity.clone())
    |                                     ^^ function or associated item not found in `Config`
    |
note: if you're trying to build a new `libp2p::libp2p_noise::Config`, consider using `libp2p::libp2p_noise::Config::new` which returns `Result<libp2p::libp2p_noise::Config, libp2p::libp2p_noise::Error>`
   --> /home/mcelrath/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libp2p-noise-0.46.0/src/lib.rs:101:5
    |
101 |     pub fn new(identity: &identity::Keypair) -> Result<Self, Error> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0599`.
error: could not compile `relay_test_client_2` (bin "relay_test_client_2") due to 1 previous error

where in this case we want to parse /home/mcelrath/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libp2p-noise-0.46.0/src/lib.rs and feed it to the LLM before asking it to fix the bug. Without this, the LLM will hallucinate the functions and parameters involved.

There are many ways this tool could work. It could respond with a class structure, function signature, or the code of a function. (I want to reduce context here, so it would be better to use tree-sitter to find the relevant parts of the file so as to not have to give the LLM the entire file)

This is language-specific and will require different branches/functions for each language. Python, go, js generally have the source being referenced somewhere on disk. C/C++ may not and may be using an interface .h file and a static or dynamically linked library.

There's a way to do this (specifically for the problem of solving compiler errors) where the dependencies are automatically provided. This ticket is to provide a tool that an AI can choose to use or not in the course of its reasoning.

Compilers always know exactly which code they're looking at, because of Makefiles, Cargo.toml, requirements.txt, pyproject,toml, etc. The goal here is to obtain exactly the same thing the compiler is seeing in a tool, using the compiler's own tools.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions