Skip to content

fix(event): avoid Jackson 3 type property conflict#1949

Open
guslegend0510 wants to merge 2 commits into
agentscope-ai:mainfrom
guslegend0510:fix/1948-agent-event-jackson3
Open

fix(event): avoid Jackson 3 type property conflict#1949
guslegend0510 wants to merge 2 commits into
agentscope-ai:mainfrom
guslegend0510:fix/1948-agent-event-jackson3

Conversation

@guslegend0510

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.0.0-SNAPSHOT

Description

Closes #1948.

This PR fixes io.agentscope.core.event.AgentEvent serialization failures under Jackson 3, especially when events are streamed through Spring MVC SseEmitter / ResponseBodyEmitter.

Root cause

AgentEvent used:

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")

At the same time, the event hierarchy exposes getType(). Under Jackson 3 this causes a serializer conflict between the synthetic type-id property and the bean property named type, which leads to:

InvalidDefinitionException: Conflict between type id property 'type' and bean property with same name

Changes

  • Change AgentEvent polymorphic type handling from JsonTypeInfo.As.PROPERTY to JsonTypeInfo.As.EXISTING_PROPERTY
  • Keep the existing getType() contract as the single source of the serialized type field
  • Add regression tests for:
    • AgentStartEvent serialization containing exactly one type field
    • polymorphic deserialization from AgentEvent base type

How to test

Run targeted regression tests:

mvn -pl agentscope-core test -Dtest=AgentEventStreamTest

I also ran:

mvn -pl agentscope-core test

The event/Jackson-related tests passed. Two existing Windows-specific symlink permission tests failed in my environment and appear unrelated to this change:

  • DangerousPathBypassTest.symlinkToDotEnvIsDetected
  • DangerousPathBypassTest.symlinkToSshIsDetected

Checklist

  • Code has been formatted with mvn spotless:apply
  • All relevant tests are passing (mvn -pl agentscope-core test -Dtest=AgentEventStreamTest)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (not needed for this internal serialization fix)
  • Code is ready for review

@guslegend0510 guslegend0510 requested a review from a team June 27, 2026 23:25
@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread agentscope-core/src/test/java/io/agentscope/core/event/AgentEventStreamTest.java Outdated

@itxaiohanglover itxaiohanglover left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean fix. Switching from As.PROPERTY to As.EXISTING_PROPERTY resolves the Jackson conflict between the type-id property and the bean property named type. The test coverage for both serialization (single type property) and deserialization (polymorphic) looks solid.

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.

[Bug]:io.agentscope.core.event.AgentEvent Deserialize error

4 participants