@@ -11,7 +11,6 @@ import (
1111 "io"
1212 "net/http"
1313 "net/url"
14- "os"
1514 "strconv"
1615
1716 "azureaiagent/internal/version"
@@ -34,6 +33,9 @@ func NewAgentClient(endpoint string, cred azcore.TokenCredential) *AgentClient {
3433 userAgent := fmt .Sprintf ("azd-ext-azure-ai-agents/%s" , version .Version )
3534
3635 clientOptions := & policy.ClientOptions {
36+ Logging : policy.LogOptions {
37+ IncludeBody : true ,
38+ },
3739 PerCallPolicies : []policy.Policy {
3840 runtime .NewBearerTokenPolicy (cred , []string {"https://ai.azure.com/.default" }, nil ),
3941 azsdk .NewMsCorrelationPolicy (),
@@ -104,8 +106,6 @@ func (c *AgentClient) CreateAgent(ctx context.Context, request *CreateAgentReque
104106 return nil , fmt .Errorf ("failed to set request body: %w" , err )
105107 }
106108
107- c .logRequest ("POST" , url , payload )
108-
109109 resp , err := c .pipeline .Do (req )
110110 if err != nil {
111111 return nil , fmt .Errorf ("HTTP request failed: %w" , err )
@@ -126,7 +126,6 @@ func (c *AgentClient) CreateAgent(ctx context.Context, request *CreateAgentReque
126126 return nil , fmt .Errorf ("failed to parse response: %w" , err )
127127 }
128128
129- c .logResponse (body )
130129 return & agent , nil
131130}
132131
@@ -148,8 +147,6 @@ func (c *AgentClient) UpdateAgent(ctx context.Context, agentName string, request
148147 return nil , fmt .Errorf ("failed to set request body: %w" , err )
149148 }
150149
151- c .logRequest ("POST" , url , payload )
152-
153150 resp , err := c .pipeline .Do (req )
154151 if err != nil {
155152 return nil , fmt .Errorf ("HTTP request failed: %w" , err )
@@ -170,7 +167,6 @@ func (c *AgentClient) UpdateAgent(ctx context.Context, agentName string, request
170167 return nil , fmt .Errorf ("failed to parse response: %w" , err )
171168 }
172169
173- c .logResponse (body )
174170 return & agent , nil
175171}
176172
@@ -284,8 +280,6 @@ func (c *AgentClient) CreateAgentVersion(ctx context.Context, agentName string,
284280 return nil , fmt .Errorf ("failed to set request body: %w" , err )
285281 }
286282
287- c .logRequest ("POST" , url , payload )
288-
289283 resp , err := c .pipeline .Do (req )
290284 if err != nil {
291285 return nil , fmt .Errorf ("HTTP request failed: %w" , err )
@@ -306,7 +300,6 @@ func (c *AgentClient) CreateAgentVersion(ctx context.Context, agentName string,
306300 return nil , fmt .Errorf ("failed to parse response: %w" , err )
307301 }
308302
309- c .logResponse (body )
310303 return & agentVersion , nil
311304}
312305
@@ -579,8 +572,6 @@ func (c *AgentClient) StartAgentContainer(ctx context.Context, agentName, agentV
579572 return nil , fmt .Errorf ("failed to set request body: %w" , err )
580573 }
581574
582- c .logRequest ("POST" , url , payload )
583-
584575 resp , err := c .pipeline .Do (req )
585576 if err != nil {
586577 return nil , fmt .Errorf ("HTTP request failed: %w" , err )
@@ -606,7 +597,6 @@ func (c *AgentClient) StartAgentContainer(ctx context.Context, agentName, agentV
606597 Body : operation ,
607598 }
608599
609- c .logResponse (body )
610600 return result , nil
611601}
612602
@@ -809,31 +799,3 @@ func (c *AgentClient) GetAgentContainerOperation(ctx context.Context, agentName,
809799
810800 return & operation , nil
811801}
812-
813- // Helper methods
814-
815- // logRequest logs the request details to stderr for debugging
816- func (c * AgentClient ) logRequest (method , url string , payload []byte ) {
817- fmt .Fprintf (os .Stderr , "%s %s\n " , method , url )
818- if len (payload ) > 0 {
819- var prettyPayload interface {}
820- if err := json .Unmarshal (payload , & prettyPayload ); err == nil {
821- prettyJSON , _ := json .MarshalIndent (prettyPayload , "" , " " )
822- fmt .Fprintf (os .Stderr , "Payload:\n %s\n " , string (prettyJSON ))
823- } else {
824- fmt .Fprintf (os .Stderr , "Payload: %s\n " , string (payload ))
825- }
826- }
827- }
828-
829- // logResponse logs the response body to stderr for debugging
830- func (c * AgentClient ) logResponse (body []byte ) {
831- fmt .Fprintln (os .Stderr , "Response:" )
832- var jsonResponse interface {}
833- if err := json .Unmarshal (body , & jsonResponse ); err == nil {
834- prettyJSON , _ := json .MarshalIndent (jsonResponse , "" , " " )
835- fmt .Fprintln (os .Stderr , string (prettyJSON ))
836- } else {
837- fmt .Fprintln (os .Stderr , string (body ))
838- }
839- }
0 commit comments