File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,7 @@ def task(cls, task: types.Task) -> a2a_pb2.Task:
203203 if task .history
204204 else None
205205 ),
206+ metadata = cls .metadata (task .metadata ),
206207 )
207208
208209 @classmethod
@@ -660,6 +661,7 @@ def task(cls, task: a2a_pb2.Task) -> types.Task:
660661 status = cls .task_status (task .status ),
661662 artifacts = [cls .artifact (a ) for a in task .artifacts ],
662663 history = [cls .message (h ) for h in task .history ],
664+ metadata = cls .metadata (task .metadata ),
663665 )
664666
665667 @classmethod
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ def sample_task(sample_message: types.Message) -> types.Task:
5252 ],
5353 )
5454 ],
55+ metadata = {'source' : 'test' },
5556 )
5657
5758
@@ -508,3 +509,30 @@ def test_large_integer_roundtrip_with_utilities(self):
508509 assert final_result ['nested' ]['another_large' ] == 12345678901234567890
509510 assert isinstance (final_result ['nested' ]['another_large' ], int )
510511 assert final_result ['nested' ]['normal' ] == 'text'
512+
513+ def test_task_conversion_roundtrip (
514+ self , sample_task : types .Task , sample_message : types .Message
515+ ):
516+ """Test conversion of Task to proto and back."""
517+ proto_task = proto_utils .ToProto .task (sample_task )
518+ assert isinstance (proto_task , a2a_pb2 .Task )
519+
520+ roundtrip_task = proto_utils .FromProto .task (proto_task )
521+ assert roundtrip_task .id == 'task-1'
522+ assert roundtrip_task .context_id == 'ctx-1'
523+ assert roundtrip_task .status == types .TaskStatus (
524+ state = types .TaskState .working , message = sample_message
525+ )
526+ assert roundtrip_task .history == [sample_message ]
527+ assert roundtrip_task .artifacts == [
528+ types .Artifact (
529+ artifact_id = 'art-1' ,
530+ description = '' ,
531+ metadata = {},
532+ name = '' ,
533+ parts = [
534+ types .Part (root = types .TextPart (text = 'Artifact content' ))
535+ ],
536+ )
537+ ]
538+ assert roundtrip_task .metadata == {'source' : 'test' }
You can’t perform that action at this time.
0 commit comments