Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Aug 8, 2025

Add get_by_id method to Agent class

Summary

Adds a new get_by_id method to the Agent class in vlmrun/client/agent.py that retrieves agent information by ID. The method makes a GET request to /agents/{agent_id} and returns an AgentInfo object, following the same implementation pattern as other methods in the class.

This change is part of a coordinated implementation with vlm-lab (PR #941) that adds the corresponding backend endpoint.

Key changes:

  • New get_by_id(agent_id: str) -> AgentInfo method in Agent class
  • Uses the same HTTP request pattern as existing methods
  • Proper type annotations and error handling following class conventions

Review & Testing Checklist for Human

  • End-to-end functionality: Test client.agent.get_by_id("test-id") against a running vlm-lab instance to verify it works correctly
  • URL format verification: Confirm that the SDK's agents/{agent_id} URL pattern matches the backend route /agents/{agent_id} exactly
  • Error handling: Test with invalid agent IDs, empty strings, and special characters to ensure proper error responses
  • Return type verification: Verify that the returned AgentInfo object contains the expected fields and structure

Recommended test plan:

  1. Start vlm-lab server locally and install this SDK version
  2. Test: client.agent.get_by_id("test-123") and verify response structure
  3. Test edge cases: empty string, special characters, very long IDs
  4. Compare response format with client.agent.get() to ensure consistency

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    ClientCode["Client Application"]:::context
    AgentClass["vlmrun/client/<br/>agent.py"]:::major-edit  
    AgentInfo["AgentInfo<br/>Response Model"]:::context
    APIEndpoint["GET /agents/{agent_id}<br/>(vlm-lab backend)"]:::context
    
    ClientCode -->|"get_by_id(agent_id)"| AgentClass
    AgentClass -->|"HTTP GET request"| APIEndpoint
    APIEndpoint -->|"JSON response"| AgentClass
    AgentClass -->|"returns"| AgentInfo
    
    subgraph Legend
        L1["Major Edit"]:::major-edit
        L2["Minor Edit"]:::minor-edit  
        L3["Context/No Edit"]:::context
    end
    
    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB  
    classDef context fill:#FFFFFF
Loading

Notes

  • Pattern consistency: Implementation follows the same structure as existing get() method in the Agent class
  • Integration testing limitation: Could not fully test end-to-end during development due to SDK dependency issues in vlm-lab test environment
  • Coordinated change: This SDK change works together with vlm-lab PR #941 that implements the backend endpoint
  • Type safety: Proper type annotations ensure IDE support and runtime validation

Link to Devin run: https://app.devin.ai/sessions/57de09ce83e7430599fd797e49db9670
Requested by: Sudeep Pillai (@spillai)

- Add get_by_id method to retrieve agent information by ID
- Follows existing pattern of get method but uses agent ID
- Returns AgentInfo object from API response

Co-Authored-By: Sudeep Pillai <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@spillai spillai merged commit 7983536 into main Aug 12, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants