I have a number of commands that work a lot like the \ref command in that its true typeset value is only defined after an initial pass is performed. In the first pass they typeset ? - like the \ref command, and in the second pass that ? is instead a number or some string.
It would be nice if I could use these commands inside a tikzpicture environment as a parameter. Obviously, tikz errors out when it gets the LaTeX command, and even if I can get the command to expand, it still errors due to tikz trying to understand the ? on the first pass - thus breaking the compile before it can build the correct value for a second pass.
Is there a way to generically redefine a command (or tikz elements I guess?) so such commands still executes as normal on the first pass (a \ref command waits for a corresponding label to get defined so it has a value, but a generic command may execute some TeX like writing to an external file or change some settings/variables in the compile which it would still need to do on the first pass before it was defined in a way to be used in the tikzpicture env on the second pass), but it doesn't generate an error in tikz in the first pass (or the error is ignored/doesn't stop compile) so that the command gets a chance to be defined for the second pass - then have tikz actually use the command output on the second pass once it is correctly defined?
Below is a MWE for what I am looking for, using a \label and \ref combo as a simple version of what I am after, but it would be ideal if it could work on generic commands that expand into arbitrary tikz code.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\setcounter{section}{6}
\section{Introduction}\label{temp}
\ref{temp}% Should display 7
\begin{tikz}% Should display a 7 radius circle
\draw circle(\ref{temp}pt);
\end{tikz}
\setcounter{section}{13}
\section{Intro2}\label{temp2}
\ref{temp2}% Should display 14
\begin{tikz}% Should display a 14 radius circle
\draw circle(\ref{temp}pt);
\end{tikz}
\end{document}
EDIT FOR MORE INFO
The primary use case I want to apply this to is the \sage{arg} command, which on the first pass outputs a ? and writes out to an external file. That file is then processed before a second LaTeX pass. On the second pass, the \sage{arg} command grabs the definition of arg from the external file, and then the \sage{arg} command expands as the definition given by the external file.
The actual particulars of sage itself aren't really important (I think), it's more that I want to have a normal LaTeX command get run inside a tikz environment, but without stopping the compile because its initial output is just a ?. But the first pass generates something so that on the second pass the command expands into tikZ parseable code, so that in the second pass it will then actually be used in tikzpicture correctly.
In particular, I would actually expect any solution for this, to also work for \label and \ref, assuming that \ref is a number or somehow a string that tikz should be able to parse normally.

