Skip to content

fix(import-agent): Fix when importing agent regarding user messages#37

Merged
EmilySymonds7 merged 2 commits intomainfrom
fix-import-agent-user-messages-loading
Mar 16, 2026
Merged

fix(import-agent): Fix when importing agent regarding user messages#37
EmilySymonds7 merged 2 commits intomainfrom
fix-import-agent-user-messages-loading

Conversation

@agustin-anastasia
Copy link
Contributor

Description

Fix importagent command not importing the agent's default system messages (initial_message, forced_termination_message, no_information_message) from the Cognitive API.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Related Issues

Fixes #(issue number)

Changes Made

  • Added initial_message, forced_termination_message, and no_information_message fields to the generated agent.py class template in importagent.py
  • Added the same three fields to the agent_fields dict passed to migrations.CreateAgent(...) in the generated migration file

Testing Done

  • Unit tests pass locally
  • Added new tests for new functionality
  • Tested manually — ran python manage.py importagent <id> agents and verified the three message attributes appear in the generated agent.py and in the CreateAgent fields dict of the generated migration

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

Notes

Field mapping from Cognitive API response to BaseAgent:

Cognitive API field BaseAgent attribute
initial_message initial_message
end_message forced_termination_message
not_info_message no_information_message

Copy link

@MicaPerdomo MicaPerdomo left a comment

Choose a reason for hiding this comment

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

Review: fix(import-agent): Fix when importing agent regarding user messages

1. PR Summary

  • What it changes: Adds initial_message, forced_termination_message, and no_information_message to the generated agent.py class and the CreateAgent migration fields dict in importagent. Also adds commented-out examples in the startagent template.
  • What it solves: importagent was 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.py and the generated migration. Also import one with None values for these fields.

4. Missing or recommended tests

  • Test that generated agent.py includes the 3 message fields when present in API response
  • Test that generated agent.py handles None values without syntax errors
  • Test that the migration agent_fields dict 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.

@EmilySymonds7 EmilySymonds7 merged commit c4df0f3 into main Mar 16, 2026
13 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.

3 participants