Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Save templateId to agent state metadata

Summary

This PR implements the requested change to save templateId to the agent state metadata when received from the client in the initial prompt, and then continue using it from state metadata only.

Changes Made

  • Added template_id: str | None field to StateMetadata TypedDict in agent_session.py
  • Initialize template_id from request.template_id when creating new agent session
  • Preserve template_id when loading existing state from request.agent_state (handled automatically by existing code)

Implementation Details

The implementation follows the existing pattern in the codebase where metadata fields are defined in the StateMetadata TypedDict and initialized when creating a new agent session. The template_id will be automatically preserved when loading existing state because the existing code already handles loading the full metadata dictionary.

This is a minimal change that only adds the storage capability without modifying any existing logic that uses template_id, as requested.

Testing

  • The changes follow existing patterns and should not break any functionality
  • Template ID is now persisted in agent state and can be accessed from metadata instead of request

Link to Devin run: https://app.devin.ai/sessions/da452696c2494389ba3bf66a14b8d894
Requested by: [email protected]

- Add template_id field to StateMetadata TypedDict
- Initialize template_id from request.template_id in agent state setup
- Preserve template_id when loading existing state from request.agent_state

Co-Authored-By: [email protected] <[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
metadata: StateMetadata = {
"app_name": None,
"template_diff_sent": False,
"template_id": request.template_id,
Copy link
Collaborator

Choose a reason for hiding this comment

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

check if there is already template_id there then do not replace

- Only use request.template_id if no existing template_id in metadata
- Addresses feedback from keugenek on PR #292

Co-Authored-By: [email protected] <[email protected]>
@keugenek keugenek closed this Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants