Skip to content

Commit 78ebf9a

Browse files
trunguttdgageot
authored andcommitted
Using string for CreatedAt instead of Time
Signed-off-by: Trung Nguyen <trungutt@users.noreply.github.com>
1 parent dcd335d commit 78ebf9a

4 files changed

Lines changed: 13 additions & 14 deletions

File tree

cmd/root/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ func createUserMessageWithAttachment(agentFilename, userContent, attachmentPath
578578
Message: chat.Message{
579579
Role: chat.MessageRoleUser,
580580
MultiContent: multiContent,
581-
CreatedAt: time.Now(),
581+
CreatedAt: time.Now().Format(time.RFC3339),
582582
},
583583
}
584584
}

pkg/chat/chat.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package chat
22

33
import (
4-
"time"
5-
64
"github.com/docker/cagent/pkg/tools"
75
)
86

@@ -61,7 +59,8 @@ type Message struct {
6159
// For Role=tool prompts this should be set to the ID given in the assistant's prior request to call a tool.
6260
ToolCallID string `json:"tool_call_id,omitempty"`
6361

64-
CreatedAt time.Time `json:"created_at"`
62+
// CreatedAt is the time the message was created
63+
CreatedAt string `json:"created_at,omitempty"`
6564
}
6665

6766
type MessagePart struct {

pkg/runtime/runtime.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func (r *Runtime) RunStream(ctx context.Context, sess *session.Session) <-chan E
224224
Role: chat.MessageRoleAssistant,
225225
Content: content,
226226
ToolCalls: calls,
227-
CreatedAt: time.Now(),
227+
CreatedAt: time.Now().Format(time.RFC3339),
228228
}
229229

230230
sess.AddMessage(session.NewAgentMessage(a, &assistantMessage))
@@ -546,7 +546,7 @@ func (r *Runtime) runTool(ctx context.Context, tool tools.Tool, toolCall tools.T
546546
Role: chat.MessageRoleTool,
547547
Content: res.Output,
548548
ToolCallID: toolCall.ID,
549-
CreatedAt: time.Now(),
549+
CreatedAt: time.Now().Format(time.RFC3339),
550550
}
551551
sess.AddMessage(session.NewAgentMessage(a, &toolResponseMsg))
552552
}
@@ -587,7 +587,7 @@ func (r *Runtime) runAgentTool(ctx context.Context, handler ToolHandler, sess *s
587587
Role: chat.MessageRoleTool,
588588
Content: output,
589589
ToolCallID: toolCall.ID,
590-
CreatedAt: time.Now(),
590+
CreatedAt: time.Now().Format(time.RFC3339),
591591
}
592592
sess.AddMessage(session.NewAgentMessage(a, &toolResponseMsg))
593593
}
@@ -618,7 +618,7 @@ func (r *Runtime) addToolCancelledResponse(sess *session.Session, toolCall tools
618618
Role: chat.MessageRoleTool,
619619
Content: result,
620620
ToolCallID: toolCall.ID,
621-
CreatedAt: time.Now(),
621+
CreatedAt: time.Now().Format(time.RFC3339),
622622
}
623623
sess.AddMessage(session.NewAgentMessage(a, &toolResponseMsg))
624624
}

pkg/session/session.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func UserMessage(agentFilename, content string) *Message {
7676
Message: chat.Message{
7777
Role: chat.MessageRoleUser,
7878
Content: content,
79-
CreatedAt: time.Now(),
79+
CreatedAt: time.Now().Format(time.RFC3339),
8080
},
8181
}
8282
}
@@ -96,7 +96,7 @@ func SystemMessage(content string) *Message {
9696
Message: chat.Message{
9797
Role: chat.MessageRoleSystem,
9898
Content: content,
99-
CreatedAt: time.Now(),
99+
CreatedAt: time.Now().Format(time.RFC3339),
100100
},
101101
}
102102
}
@@ -203,7 +203,7 @@ func (s *Session) GetMessages(a *agent.Agent) []chat.Message {
203203
messages = append(messages, chat.Message{
204204
Role: "system",
205205
Content: "You are a multi-agent system, make sure to answer the user query in the most helpful way possible. You have access to these sub-agents:\n" + subAgentsStr + "\nIMPORTANT: You can ONLY transfer tasks to the agents listed above using their ID. The valid agent IDs are: " + strings.Join(validAgentIDs, ", ") + ". You MUST NOT attempt to transfer to any other agent IDs - doing so will cause system errors.\n\nIf you are the best to answer the question according to your description, you can answer it.\n\nIf another agent is better for answering the question according to its description, call `transfer_task` function to transfer the question to that agent using the agent's ID. When transferring, do not generate any text other than the function call.\n\n",
206-
CreatedAt: time.Now(),
206+
CreatedAt: time.Now().Format(time.RFC3339),
207207
})
208208
}
209209

@@ -215,15 +215,15 @@ func (s *Session) GetMessages(a *agent.Agent) []chat.Message {
215215
messages = append(messages, chat.Message{
216216
Role: chat.MessageRoleSystem,
217217
Content: a.Instruction() + "\n\n" + date,
218-
CreatedAt: time.Now(),
218+
CreatedAt: time.Now().Format(time.RFC3339),
219219
})
220220

221221
for _, tool := range a.ToolSets() {
222222
if tool.Instructions() != "" {
223223
messages = append(messages, chat.Message{
224224
Role: chat.MessageRoleSystem,
225225
Content: tool.Instructions(),
226-
CreatedAt: time.Now(),
226+
CreatedAt: time.Now().Format(time.RFC3339),
227227
})
228228
}
229229
}
@@ -240,7 +240,7 @@ func (s *Session) GetMessages(a *agent.Agent) []chat.Message {
240240
messages = append(messages, chat.Message{
241241
Role: chat.MessageRoleSystem,
242242
Content: "Session Summary: " + s.Messages[lastSummaryIndex].Summary,
243-
CreatedAt: time.Now(),
243+
CreatedAt: time.Now().Format(time.RFC3339),
244244
})
245245
}
246246

0 commit comments

Comments
 (0)