fix(import-agent): Fix when importing agent regarding user messages#37
Conversation
MicaPerdomo
left a comment
There was a problem hiding this comment.
Review: fix(import-agent): Fix when importing agent regarding user messages
1. PR Summary
- What it changes: Adds
initial_message,forced_termination_message, andno_information_messageto the generatedagent.pyclass and theCreateAgentmigration fields dict inimportagent. Also adds commented-out examples in thestartagenttemplate. - What it solves:
importagentwas fetching these fields from the API but silently dropping them — imported agents lost their default messages. - Areas affected:
importagent.py(code generation),startagent.py(template), generated agent files, generated migrations. - Risk level: Low
2. Findings
Important — startagent.py adds mandatory fields as comments
The 3 message fields are added as comments in the startagent template, but all other agent fields (max_responses, max_msg_length, temperature, etc.) are actual fields with default values. According to the agent spec, initial_message, forced_termination_message, and no_information_message are mandatory — they should be real fields with sensible defaults, not commented-out examples.
Minor — No tests
PR acknowledges no unit tests. Given the simplicity (3 lines in a template + 3 keys in a dict), manual testing is reasonable. But a test verifying the generated agent.py includes these fields when present in the API response would prevent future regressions.
Minor — startagent.py change not mentioned in PR description
The "Changes Made" section only mentions importagent.py, but the PR also modifies startagent.py.
3. Regression risks
- Low: The change is purely additive — it adds fields that were being silently dropped. Existing agents won't be affected.
- Verify manually: Import an agent that has these fields set and confirm they appear in both
agent.pyand the generated migration. Also import one withNonevalues for these fields.
4. Missing or recommended tests
- Test that generated
agent.pyincludes the 3 message fields when present in API response - Test that generated
agent.pyhandlesNonevalues without syntax errors - Test that the migration
agent_fieldsdict includes the 3 keys
5. Final verdict
Approvable with minor changes
The change is correct, minimal, and fixes a real gap. The field mapping matches the existing convention in migrate.py. Main recommendations: make the 3 fields real (not commented) in startagent, and update the PR description to mention the startagent.py change.
Description
Fix
importagentcommand not importing the agent's default system messages (initial_message,forced_termination_message,no_information_message) from the Cognitive API.Type of Change
Related Issues
Fixes #(issue number)
Changes Made
initial_message,forced_termination_message, andno_information_messagefields to the generatedagent.pyclass template inimportagent.pyagent_fieldsdict passed tomigrations.CreateAgent(...)in the generated migration fileTesting Done
python manage.py importagent <id> agentsand verified the three message attributes appear in the generatedagent.pyand in theCreateAgentfields dict of the generated migrationChecklist
Notes
Field mapping from Cognitive API response to
BaseAgent:BaseAgentattributeinitial_messageinitial_messageend_messageforced_termination_messagenot_info_messageno_information_message